On 1/1/2021 2:00 PM, Jonathan Fine wrote:
By the way, this surprised me. Would anyone like to explain this?
>>> id(f()), id(f())
(139927013695536, 139927013695536)
id's are only unique while an object exists. Here the object returned by
the first call is discarded after its id is taken. Then the second
object is created and reuses the memory address that was used by the
first object. Since in CPython id() returns object's memory address, the
id's are the same.
Eric
_______________________________________________
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/YHNHGZT5BNPXQLQ2BDT6ARNDJCHGE62M/
Code of Conduct: http://python.org/psf/codeofconduct/