A question on modification of a list via a function invocation

Steve D'Aprano steve+python at pearwood.info
Thu Sep 7 11:30:56 EDT 2017


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.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list