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

Alex Gaynor report at bugs.python.org
Sat Mar 2 18:23:39 CET 2013


New submission from Alex Gaynor:

Following the length_hint PEP, we should expose this facility to end-python programmers. The semantics would be basically: the list has behavior identical to if you hadn't provided length_hint, except the VM is free to preallocate efficiently.

CPython (and PyPy) use this kind of logic internally all over the place when lists are to be returned (including, but not limited to, list() with a single argument!)

If this is considered to be a good idea I'll whip up a patch.

----------
messages: 183332
nosy: alex
priority: normal
severity: normal
status: open
title: Add length_hint parameter to list, dict, set constructors to allow efficient presizing
type: performance
versions: Python 3.4

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


More information about the Python-bugs-list mailing list