typing icon indicating copy to clipboard operation
typing copied to clipboard

Private identity objects are not singletons.

Open Alex-Wasowicz opened this issue 7 months ago • 0 comments

In the subsection describing singletons in unions, widely used object() example is described as a singleton, but it isn't one. It should be clearly stated that the problem for typing system is that this instance is not a singleton, that's why Enum is needed.

_empty = object() works with is check, because identity of _empty doesn't leak outside of module. There is nothing singleton about that. Typing spec can allow requiring _empty to be one, to allow use with is, but that should be clear it's the case.

Alex-Wasowicz avatar Mar 24 '25 17:03 Alex-Wasowicz