old_contents: import base
  from blocks import Blocks
  import re
  
  class Sentences(base.Base):
      _type = 'sentences'
      child_class = Blocks
  
      @staticmethod
      def parse(text):
          #re.split('\!|\?|\. | \.',text)
          result = []
          prev = 0
  
          # we allow .09 as not end of sentences
          #for m in re.finditer('[\!\?]+|\.+(?:\s+|$|\?|\!)', text):
          for m in re.finditer('\.+(?:\s+|$)|(\.*)[\!\?]+(\.+(?:\s+|$))*', text):
              curr, _next = m.start(), m.end()
              # if prev position of delimiter < current - between exists text
              # at least 1 symbol.
              if prev < curr:
                  node = text[prev:curr].strip()
                  if node != '':
                      result.append(node)
              result.append(list( text[curr:_next].strip() ))
              prev = _next
          if len(text) > prev:
              result.append(text[prev:].strip())
          return result
new_contents: import base
  from blocks import Blocks
  import re
  
  class Sentences(base.Base):
      _type = 'sentences'
      child_class = Blocks
  
      @staticmethod
      def parse(text):
          _len = len(text)
          result = []
          prev = 0
  
          # we allow .09 as not end of sentences
          for m in re.finditer('[\!\?\.]+', text):
              curr, _next = m.start(), m.end()
              items = list( text[curr: _next].strip() )
  
              if (_len > _next) and not (text[_next] == ' '):
                  # delete ending '.' if they not before space or end of string
                  while (len(items) > 0) and (items[-1] == '.'):
                      items.pop()
                      _next = _next - 1
  
              if len(items) > 0:
                  # if prev position of delimiter < current - between exists text
                  # at least 1 symbol.
                  if prev < curr:
                      node = text[prev:curr].strip()
                      if node != '':
                          result.append(node)
                  result.append( items )
                  prev = _next
          if _len > prev:
              result.append(text[prev:].strip())
          return result
subject: Optimize from 5-6s to 2.9-3.0