This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients celicoo, steven.daprano
Date 2018-05-29.16:46:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527612389.73.0.682650639539.issue33685@psf.upfronthosting.co.za>
In-reply-to
Content
ID numbers in Python are only guaranteed to be unique for the lifespan of the object. In CPython they can be re-used. (In other implementations, like Jython and IronPython, IDs are allocated as sequential numbers and won't be reused.)

The other fact you may be missing is that method objects are generated on the fly each time you look them up. So:


py> class X:
...     def method(self): pass
...
py> x = X()
py> a = x.method
py> b = x.method
py> a is b
False

So your example is now understandable: you generate a method object, get its ID, and then the method object is garbage collected, allowing the ID to be reused. Which *in this case* it is. Whether it is or isn't re-used is an accident of implementation.

In other words: nothing to see here. Its not a bug, just the normal behaviour of IDs and garbage collection.
History
Date User Action Args
2018-05-29 16:46:29steven.dapranosetrecipients: + steven.daprano, celicoo
2018-05-29 16:46:29steven.dapranosetmessageid: <1527612389.73.0.682650639539.issue33685@psf.upfronthosting.co.za>
2018-05-29 16:46:29steven.dapranolinkissue33685 messages
2018-05-29 16:46:29steven.dapranocreate