Raymond Hettinger added the comment:

Guido has previously rejected any kind of user specified presizing parameter 
for dictionaries.  He felt that it was breaking the abstraction in a way that 
caused people to focus on implementation specific details.

Also, set() and dict() use presizing (and hash value reuse) only in the limited 
case of the input iterable being an exact dictionary or set.  Otherwise, it 
makes no assumptions about the input iterable and grows as needed.  For sets, 
even when the __len__ is known for a general iterable, we don't know how many 
unique elements are the input -- consider for example: set([None] * 1000000).  
In typical use cases for sets, a user also doesn't know in advance how many 
unique elements will be present -- and to the extent they try to add estimation 
logic, it would only complicate their programs.

----------
nosy: +rhettinger

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

Reply via email to