Raymond Hettinger <raymond.hettin...@gmail.com> added the comment: We should remove the documentation entries that discuss non-guaranteed implementation details (i.e. which integers are singletons).
Instead, there should probably be a brief tutorial entry on what aspects of object identity people can rely on: * None, True, and False are singletons. PEP 8 recommends testing for None with "is". * Most internal equality comparisons (i.e. that in list.count or list.__contains__) assume that identity-implied-equality regardless of how __eq__ is defined (i.e. an object is always equal to itself). * Once created, an object doesn't change its identity. So, you can use "is" to find the exact same object at a later stage in a program. * Unless documented otherwise (a singleton class telling you that it returns the same object every time), no other assumptions should be made about object identity. In particular, one cannot assume that an object id won't be re-used after the object is reclaimed. ---------- nosy: +rhettinger _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11846> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com