Hacker News new | ask | show | jobs
by zahlman 336 days ago
`id()` is documented and mandated to exist, and the result provides guarantees that make it suitable for identity (not equality) checks[1] (although of course you should normally use the `is` operator). Pitfalls involving it are generally really pitfalls with understanding object lifetimes[2].

[1]: https://docs.python.org/3/library/functions.html#id

[2]: see e.g. https://stackoverflow.com/questions/52096582