Message241297
You shouldn't presize when the input is a potentially non-unique iterable. It makes sense to presize for inputs of type dict or set, but for a list, the assumption is that many duplicates will be present, since deduping is a common use case for dicts (less so with the advent of sets, but still common enough to support without massive overallocation of memory).
In short, dict([(1, 2)] * 1000000) should not involve allocating GB of memory for the dict up front. |
|
Date |
User |
Action |
Args |
2015-04-17 00:06:55 | josh.r | set | recipients:
+ josh.r, rhettinger, larry, benjamin.peterson, mpm, marmoute |
2015-04-17 00:06:55 | josh.r | set | messageid: <1429229215.93.0.245584199973.issue23971@psf.upfronthosting.co.za> |
2015-04-17 00:06:55 | josh.r | link | issue23971 messages |
2015-04-17 00:06:55 | josh.r | create | |
|