[issue17338] Add length_hint parameter to list, dict, set constructors to allow efficient presizing

Charles-François Natali report at bugs.python.org
Tue Mar 5 20:58:04 CET 2013


Charles-François Natali added the comment:

> Here is an experimental patch. The speedup is ... measurable.

It's likely to be more useful for dict and set, to avoid/limit rehashs.
Also, the allocation overhead depends on the implementation, I suspect the gain would be more important with PyPy.

FWIW, Java proposes this for lists and maps, but I'm not convinced exposing such tunables really makes sense for Python.

----------
nosy: +neologix

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17338>
_______________________________________


More information about the Python-bugs-list mailing list