A question on modification of a list via a function invocation

Ben Bacarisse ben.usenet at bsb.me.uk
Fri Sep 8 06:20:32 EDT 2017


Steve D'Aprano <steve+python at pearwood.info> writes:

> On Fri, 8 Sep 2017 12:28 am, Chris Angelico wrote:
>
>> languages without mutable objects don't
>> really care whether they're pass-by-X or pass-by-Y.
>
> Only if you don't care about efficiency.
>
> Believe me, the first time you pass a five gigabyte array to a function using
> pass-by-value, on a machine with only six gigabytes of memory, you'll care.

I think your general idea to separate language semantics from
implementation details is a good one, but you've dropped it here.  A
language with call-by-value semantics need not copy large objects when
passing them to a function.  The program must behave *as if* there is a
copy but there need not actually be one.

<snip>
-- 
Ben.



More information about the Python-list mailing list