[Python-3000] Set literal

Georg Brandl g.brandl at gmx.net
Sat Jan 26 23:02:25 CET 2008


Guido van Rossum schrieb:
> 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.

Which means of course that users will pick up that idiom when they're
creating nonempty sets in their own code, thus causing the issues
Raymond mentioned.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-3000 mailing list