old_contents: """
      ks.sequence
      ~~~~~~~~~~~
      Implements a tuple-like object on top of the
      standard stream class, for cases where the
      values needed to be accessed by index, lazily.
  """
  
  
  from ks.stream import Stream
  
  
  class Sequence(Stream):
      """
      A sequence is a special case of a stream where
      the values can be accessed lazily, but previous
      values are preserved, similar to a tuple that it
      is a read-only structure.
      """
  
      def __init__(self, *args, **kwargs):
          self.superclass = super(Sequence, self)
          self.superclass.__init__(*args, **kwargs)
          self.loaded = []
  
      def load(self, n):
          """
          Load at most *n* elements from a stream into
          the internal cache.
  
          :param n: The number of elements to load.
          """
          it = self.superclass.__iter__()
          for _ in range(n):
              try:
                  self.loaded.append(next(it))
              except StopIteration:
                  break
  
      def __len__(self):
          return len(self.loaded)
  
      count = __len__
  
      def __getitem__(self, idx):
          size = len(self)
          if idx >= size:
              self.load((idx + 1) - size)
          return self.loaded[idx]
  
      def __iter__(self):
          for item in self.loaded:
              yield item
  
          for item in self.superclass.__iter__():
              self.loaded.append(item)
              yield item
  
      def index(self, elem):
          """
          Check for the index of an element, given that
          the element is within the sequence. Else,
          raise a ValueError.
  
          :param elem: The element to index.
          """
          for index, item in enumerate(self):
              if item == elem:
                  return index
          raise ValueError
  
new_contents: """
      ks.sequence
      ~~~~~~~~~~~
      Implements a tuple-like object on top of the
      standard stream class, for cases where the
      values needed to be accessed by index, lazily.
  """
  
  
  from collections import Sequence as _Seq
  from ks.stream import Stream
  
  
  class Sequence(Stream, _Seq):
      """
      A sequence is a special case of a stream where
      the values can be accessed lazily, but previous
      values are preserved, similar to a tuple that it
      is a read-only structure.
      """
  
      def __init__(self, *args, **kwargs):
          self.superclass = super(Sequence, self)
          self.superclass.__init__(*args, **kwargs)
          self.loaded = []
  
      def load(self, n):
          """
          Load at most *n* elements from a stream into
          the internal cache.
  
          :param n: The number of elements to load.
          """
          it = self.superclass.__iter__()
          for _ in range(n):
              try:
                  self.loaded.append(next(it))
              except StopIteration:
                  break
  
      def __len__(self):
          return len(self.loaded)
  
      def __getitem__(self, idx):
          size = len(self)
          if idx >= size:
              self.load((idx + 1) - size)
          return self.loaded[idx]
  
      def __iter__(self):
          for item in self.loaded:
              yield item
  
          for item in self.superclass.__iter__():
              self.loaded.append(item)
              yield item
  
subject: use mixin class