code: def extend_memory(self, start_position: int, size: int) -> None:
          
          validate_uint256(start_position, title="Memory start position")
          validate_uint256(size, title="Memory size")
  
          before_size = ceil32(len(self._memory))
          after_size = ceil32(start_position + size)
  
          before_cost = memory_gas_cost(before_size)
          after_cost = memory_gas_cost(after_size)
  
          if self.logger.show_debug2:
              self.logger.debug2(
                  "MEMORY: size (%s -> %s) | cost (%s -> %s)",
                  before_size,
                  after_size,
                  before_cost,
                  after_cost,
              )
  
          if size:
              if before_cost < after_cost:
                  gas_fee = after_cost - before_cost
                  self._gas_meter.consume_gas(
                      gas_fee,
                      reason=" ".join((
                          "Expanding memory",
                          str(before_size),
                          "->",
                          str(after_size),
                      ))
                  )
  
              self._memory.extend(start_position, size)
docs: Extend the size of the memory to be at minimum ``start_position + size``
          bytes in length.  Raise `eth.exceptions.OutOfGas` if there is not enough
          gas to pay for extending the memory.