id() Object identity
Last updated: 2026-09-22
id() Object identity
id() returns the integer identity of an object (typically its memory address). Objects with the same id satisfy a is b.
| Category | Built-in Functions |
|---|---|
| Kind | Built-in Function |
| Python Version | all |
📝 Syntax
id(object)
⚙️ Parameters
| object Required | Any object whose identity is returned. |
|---|
Returns:The integer identity of the object (usually its memory address in CPython).
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
True
💡 Related Cases
More case studies coming soon — check back later.
❓ FAQ
QWhat does id() return?
AA unique identity integer for the object; in CPython it is usually the object's memory address.
QWhy does id(a) == id(b) not prove that a == b?
ATwo variables may reference the same object (then the ids are equal and so are the contents). The real pitfall is the other way: different objects can share an id when the address is reused after garbage collection, or via small-integer/short-string interning. Use == for equality and is for identity.
QWhat are the practical uses of id()?
ADuring debugging it confirms whether two variables reference the same object (together with is), or inspects object caching/interning behavior, such as why small integers share an id.
QCan an object's id change?
AA live object's id never changes; however once an object is garbage-collected, its id may be reused by a newly created object.