Message336916
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. |
|
Date |
User |
Action |
Args |
2019-03-01 13:30:00 | steven.daprano | set | recipients:
+ steven.daprano, methane, lgj1993 |
2019-03-01 13:30:00 | steven.daprano | link | issue36156 messages |
2019-03-01 13:30:00 | steven.daprano | create | |
|