Re: [Python-Dev] When do sets shrink?
by Raymond Hettinger other posts by this author
Dec 31 2005 12:54PM messages near this date
Re: [Python-Dev] When do sets shrink?
|
Re: [Python-Dev] When do sets shrink?
[Noam]
> For example, iteration over a set which once had
> 1,000,000 members and now has 2 can take 1,000,000 operations every
> time you traverse all the (2) elements.
Do you find that to be a common or plausible use case?
Was Guido's suggestion of s=set(s) unworkable for some reason? dicts
and sets emphasize fast lookups over fast iteration -- apps requiring
many iterations over a collection may be better off converting to a list
(which has no dummy entries or empty gaps between entries).
Would the case be improved by incurring the time cost of 999,998 tests
for possible resizing (one for each pop) and some non-trivial number of
resize operations along the way (each requiring a full-iteration over
the then current size)?
Even if this unique case could be improved, what is the impact on common
cases? Would a downsizing scheme risk thrashing with the
over-allocation scheme in cases with mixed adds and pops?
Is there any new information/research beyond what has been obvious from
the moment the dict resizing scheme was born?
Raymond
_______________________________________________
Python-Dev mailing list
Python-Dev@[...].org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.c
om
Thread:
Noam Raphael
Noam Raphael
Fernando Perez
Raymond Hettinger
Raymond Hettinger
Noam Raphael
Tim Peters
Josiah Carlson
Raymond Hettinger
"Martin v. Löwis"
Fredrik Lundh
Noam Raphael
Josiah Carlson
Donovan Baarda
Fredrik Lundh
Noam Raphael
"Martin v. Löwis"
Adal Chiriliuc
1
Adal Chiriliuc
Raymond Hettinger
Donovan Baarda
Noam Raphael
Guido van Rossum
Noam Raphael
Josiah Carlson
"Martin v. Löwis"
Noam Raphael
|