[Python-3000] set literals

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Jul 10 18:39:03 CEST 2006


Guido van Rossum:
> # We could use these equivalencies:
> assert {1} == {1: None} == set({1: "a"})   # I.e. canonical sets have
> all None values

An alternative canonical representation of a set as a dict could be a
dict d for which d[k] is k for k in d.keys().


Guido van Rossum:
> Also, sets would grow some operations that don't make a lot of sense
> (e.g. __getitem__, get, setdefault) but that's minor once you know the
> same implementation is used.

These operations will see some use if sets behave as identity
dictionaries, for example, setdefault will become an interning
operation.


More information about the Python-3000 mailing list