A question on modification of a list via a function invocation

Chris Angelico rosuav at gmail.com
Thu Sep 7 12:24:16 EDT 2017


On Fri, Sep 8, 2017 at 1:30 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> 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.
>
> Preventing that sort of thing is probably why arrays aren't first-class values
> in C, and you cannot pass an array as argument, only a pointer to an array. But
> Pascal will happily assume you know what you're doing if you declare an array
> parameter without "var", and copy the whole array.

Right - but sharing (in whatever form) is a pure optimization, with no
visible semantics.

ChrisA



More information about the Python-list mailing list