[Python-3000] Set literal
Raymond Hettinger
python at rcn.com
Sat Jan 26 22:45:45 CET 2008
>>> should the repr for a set be set({a, b, c}) instead of set([a, b, c])?
[Raymond]
>> FWIW, running eval() on the repr is slower and less memory efficient with curly braces than with the square brackets.
[Ron]
> It's all very close. I think the frozenset({1,2,3}) example will get faster if {..} notation becomes a frozen set, and set({...})
> example will slow down a bit.
Am strongly -1 on changing the repr for set to set({a, b, c}) . Creating an innermost frozenset doubles the memory consumption.
Also, it invisibly pushes the hashing inward one step which will lead to weird tracebacks with set subclasses (it should be the
outermost that raises an exception, not the innermost). I find the notation to be confusing. I am strongly against this change and
would like to see it reverted right away. As the caretaker of this code, hopefully my recommendation will carry some weight. I'm
not happy with this change.
Raymond
More information about the Python-3000
mailing list