bpo-33234 Improve list() pre-sizing for inputs with known lengths (no __length_hint__) by pablogsal · Pull Request #9846 · python/cpython

added 2 commits

April 17, 2018 21:51
The list() constructor isn't taking full advantage of known input
lengths or length hints. This commit makes the constructor
pre-size and not over-allocate when the input size is known or
can be reasonably estimated.

A new test is added to test_list.py and a test needed to be modified
in test_descr.py as it assumed that there is only one call to
__length_hint__() in the list constructor.

vstinner

@pablogsal

vstinner

vstinner

@pablogsal

serhiy-storchaka

@pablogsal

vstinner

@pablogsal

@pablogsal

serhiy-storchaka

@pablogsal

vstinner

@pablogsal

vstinner

@pablogsal

vstinner

serhiy-storchaka