On 01/01/2021 19:00, Jonathan Fine wrote:
By the way, this surprised me. Would anyone like to explain this?
>>> id(f()), id(f())
(139927013695536, 139927013695536)
That made me think. The result of the first f() has gone out of scope by
the time the second call, and so the id (that is, the memory) is
available next time CPython needs a place for an int of about the same
bit_length.
>>> def f(): return 10**1000
>>> def g(): return 9**1048
>>> id(f()), id(g())
(2149044150320, 2149044150320)
Neat demonstration that the id of an object is only unique in its lifetime.
Jeff
_______________________________________________
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/PW3SYSZMAFSJCB6VBEZXPWJF5BNZSYVM/
Code of Conduct: http://python.org/psf/codeofconduct/