code: def _create_slice(self, key):
          
  
          if isinstance(key, slice):
              step = key.step
              if step is None:
                  step = 1
  
              if step != 1:
                  raise ArgumentError("You cannot slice with a step that is not equal to 1", step=key.step)
  
              start_address = key.start
              end_address = key.stop - 1
  
              start_i, start_seg = self._find_address(start_address)
              end_i, _end_seg = self._find_address(end_address)
  
              if start_seg is None or start_i != end_i:
                  raise ArgumentError("Slice would span invalid data in memory",
                                      start_address=start_address, end_address=end_address)
  
              block_offset = start_address - start_seg.start_address
              block_length = end_address - start_address + 1
  
              return start_seg, block_offset, block_offset + block_length
          elif isinstance(key, int):
              start_i, start_seg = self._find_address(key)
              if start_seg is None:
                  raise ArgumentError("Requested invalid address", address=key)
  
              return start_seg, key - start_seg.start_address, None
          else:
              raise ArgumentError("Unknown type of address key", address=key)
docs: Create a slice in a memory segment corresponding to a key.