[Python-Dev] When do sets shrink?

Josiah Carlson jcarlson at uci.edu
Thu Dec 29 06:03:50 CET 2005


Noam Raphael <noamraph at gmail.com> wrote:
> 
> On 12/29/05, Raymond Hettinger <raymond.hettinger at verizon.net> wrote:
> > What could be done is to add a test for excess dummy entries and trigger
> > a periodic resize operation.  That would make the memory available for
> > other parts of the currently running script and possibly available for
> > the O/S.
> >
> > The downside is slowing down a fine-grained operation like pop().  For
> > dictionaries, this wasn't considered worth it.  For sets, I made the
> > same design decision.  It wasn't an accident.  I don't plan on changing
> > that decision unless we find a body of real world code that would be
> > better-off with more frequent re-sizing.
> 
> The computer scientist in me prefers O() terms over changes in a
> constant factor, but that's only me. Perhaps a note about it should be
> added to the documentation, though?

The computer scientist in me agrees with you, but the practical
application developer in me argues that every microsecond adds up.

 - Josiah



More information about the Python-Dev mailing list