The python language reference mentions three objects which have a single, unique instance: None
, NotImplemented
, and Ellipsis
(section 3.2 "The Standard Type Hierarchy"). The test x is None
is a common idiom made possible by the guaranteed uniqueness of None
. I cannot find any other mention of unique-instance objects, either in python documentation or on stack overflow. A few questions, like this one have interesting suggestions for ways to construct such objects, but what I want to know is whether there are any beyond these three built-ins that I've missed.
For example, ()
appears to be unique (in admittedly very limited testing in CPython), so is the test x is ()
safe? Or is x == ()
mandatory for this case?