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.

CategoryBuilt-in Functions
KindBuilt-in Function
Python Versionall

📝 Syntax

id(object)

⚙️ Parameters

object RequiredAny 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
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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏