[Python-3000] set literals
Nick Coghlan
ncoghlan at gmail.com
Mon Jul 10 12:19:59 CEST 2006
Guido van Rossum wrote:
> I've also sometimes thought of unifying dicts and sets by implementing
> set operations on the keys of dicts only. When the values aren't the
> same, we could make an arbitrary decision e.g. the left operand wins.
If the right operand always won then a |= b would be equivalent to a.update(b).
> # And of course it would solve the empty set notation problem nicely:
> assert dict() == {} == set()
So dicts would always start life using the set implementation, and switch to
the full dict implementation only when a non-None value was added?
> Unfortunately we couldn't redefine <=, <, >=, > to mean various
> subset/superset tests without backwards incompatibilities (but does
> anyone care?
You mean those are defined *now*? I'm trying to figure out what the heck they
could even mean. . .
> I still expect there's a fatal flaw in the scheme, but I can't think
> of it right now...
If you've got an idea of how to handle the promotion from the set
implementation to the dict implementation when a non-None value is entered,
then I can't see any fatal flaws, either.
I'm sure Raymond will be able to come up with something, though :)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list