I agree that is how python is implemented, and from a memory perspective, this is not needed. What I was talking about was more from a conceptual resource point of view, and not just memory as a resource.

Consider a generator, you can have many different bindings to the object, but when it is exhausted, it may not make sense to access that that generator though one of the other bindings. Of course accessing it can raise an exception, or you can have objects you can ask of the resources are still "valid" for whatever the resource is (in this case a generator), rebind a name after a function call with additional checks, etc.

It would be convenient if you could mark in source code that you intended a resource to be "moved" and any further access through other bindings are not what was intended. This would help catch logic bugs during type checking, instead of hitting this issue at runtime.

On Thu, Nov 26, 2020, 1:42 PM Richard Damon <Richard@damon-family.org> wrote:
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-leave@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/