[New-bugs-announce] [issue36156] different method, but id function return same value.

lgj report at bugs.python.org
Fri Mar 1 05:01:47 EST 2019


New submission from lgj <929102624 at qq.com>:

>>> class A:
...     def a(self):
...         return 0
...     def a1(self):
...         return 1
...
>>> a =A()
>>> id(a.a)
4316559496
>>> id(a.a1)
4316559496
>>> id(a)
4318155272
It' seems oops , according to the id function source code.
here is the description of builtin_id function in Python/bltinmodule.c
/* 
Return the identity of an object.

This is guaranteed to be unique among simultaneously existing objects.
(CPython uses the object's memory address.)
[clinic start generated code]*
/
It seems should return different value, but id(a.a) as same as 
id(a.a1), Is it a bug?

----------
components: Library (Lib)
messages: 336912
nosy: lgj1993
priority: normal
severity: normal
status: open
title: different method, but id function return same value.
type: behavior
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36156>
_______________________________________


More information about the New-bugs-announce mailing list