[Python-3000] Set literal

Guido van Rossum guido at python.org
Sat Jan 26 22:50:37 CET 2008


On Jan 26, 2008 1:45 PM, Raymond Hettinger <python at rcn.com> wrote:
> Am strongly -1 on changing the repr for set to set({a, b, c}) .   Creating an innermost frozenset doubles the memory consumption.

Raymond, I think you're overestimating how often the repr() of a set
actually gets eval()'ed. I expect this happens approximately never. I
certainly haven't used it myself, and most certainly not in a
performance-critical context.

The reason that repr() returns an eval()'able expression isn't that
the expression is likely to be eval()'ed -- it is that the programmer
is already familiar with the notation and can thus immediately
understand what it means.

>From an understandability POV, set({...}) is simpler than set([...])
because the list is just a distraction.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list