[Python-3000] Set literal
Guido van Rossum
guido at python.org
Sat Jan 26 23:11:43 CET 2008
On Jan 26, 2008 2:02 PM, Georg Brandl <g.brandl at gmx.net> wrote:
> 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.
But didn't we start by establishing that users are rarely going to
create non-empty non-frozen sets anyway, because most algorithms
involving mutable sets start with an empty one? Even if users
occasionally write initialized sets, I find it hard to believe that
this would occur in a performance-critical position.
I think Raymond has been focusing on performance for so long that he
sees performance issues *everywhere*. It reminds me of the ugly idioms
that were common in Zope (long ago, it's probably changed) because
they boosted performance -- unfortunately they were used everywhere,
not just in performance-critical code, making the code harder to read
and maintain.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list