On Fri, Mar 13, 2020 at 4:39 AM Marco Sulla
<[email protected]> wrote:
>
> On Thu, 12 Mar 2020 at 18:19, Chris Angelico <[email protected]> wrote:
> > No, it wouldn't - the use of the value as a return value counts as a
> > reference. It's exactly the same as any other function that returns a
> > brand-new value.
>
> So the memory of that object will never free... since there's a
> reference that can't be deleted, until the current scope is not
> finished.
> This in practice will break `del variable`

I suspect you're misunderstanding the way references are counted
somewhere, but I'm not sure where. An object being used in an
expression is referenced by being "currently in use" and won't be
disposed of (in CPython, it's on the internal stack of objects that's
used by the evaluator), but you don't have to "delete" this reference
in any way.

The action of deleting a *name* is not the same as disposing of an
*object*. You can consider "del x" to be very similar to "x = None",
except that instead of rebinding to some other object, it unbinds x
altogether. Whatever behaviour you would expect of "x = None" in terms
of the previous value for x, the same will be true of "del x".

ChrisA
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/G3ZG2QJK7B2CZZEEVDU73LLKP6KJMDAX/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to