Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
bugs.python.org seems to be down at the moment, so please forgive me if this ticket has already been closed and I'm repeating what has already been said. > This is guaranteed to be unique among simultaneously existing objects. Note the *simultaneously existing* comment. Since the method objects a.a and a.a1 don't exist simultaneously, the interpreter is allowed to reuse the same ID for each. (P.S. please, next time use less confusing names!) Your code does this: - fetch a.a, which returns a new method object; - print the ID of that method object; - throw away and garbage collect the method object; - fetch a.a1, which returns a new method object; - print the ID of that method object which happens to get the same value as the previous object; - throw away and garbage collect the method object. You can see the difference if you do this: spam = a.a eggs = a.a1 print(id(spam), id(eggs)) and you will get two different IDs. ---------- nosy: +steven.daprano _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36156> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com