On Mar 12, 2020, at 10:52, Marco Sulla via Python-ideas 
<python-ideas@python.org> wrote:
> 
> On Thu, 12 Mar 2020 at 18:19, Chris Angelico <ros...@gmail.com> 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`

No, because the return value only lives until (effectively) the end of the 
statement. A statement has no value, so the effect of an expression statement 
is to immediately discard whatever the value of the expression was. (In CPython 
this is an explicit stack pop.)

Except for the case of interactive mode, of course, where an expression 
statement binds the value to the _ variable.
_______________________________________________
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/3SMXCZVC2IWNK246QQZUFAM4H66VMTLK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to