On 11/26/20 12:07 PM, Guido van Rossum wrote:
> This reminds me of something in C++. Does it exist in other languages?
>
A key point is that C++ needs 'move' behavior as its variables are
buckets of bits, and assigning one variable to another, like in a call,
requires copying that whole bucket of bits, and if it refers to other
buckets of bits, may need to copy them too.

One thing that can be done when making this assignment, if the original
isn't going to be needed is to 'steal' those buckets that the first
object pointed to, possibly saving a lot of work.

Python doesn't need to do this, as it isn't based on a bucket of bits
type model, but its names are just bound to objects, and can readily share.

Another way to think of the issue is it is mostly an issue with using
Call By Value, which is the basic way to pass parameters in C and C++
(there is also a 'Call By Reverence' which is really just a Call by
Value, where the value is a pointer, maybe with syntactic sugar to hide
the pointerness)

Python doesn't use Call by Value, but its method is better described as
Call by Binding, the parameters in the function are bound to the pbjects
specified in the call. If those objects are mutable, the function can
change the object that the caller gave, but can't 'rebind' any variable
names in the call statement to new objects.

-- 
Richard Damon
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/5VKCC6OIDEFX74UUYAA77RZR4KJREUO4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to