Josh Rosenberg added the comment:

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.

----------
nosy: +josh.r

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23971>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to