New submission from Raymond Hettinger <raymond.hettin...@gmail.com>:

The list() constructor isn't taking full advantage of known input lengths or 
length hints.  Ideally, it should pre-size and not over-allocate when the input 
size is known or can be reasonably estimated.

Python 3.8.0a0 (heads/master:091e95e900, Apr  5 2018, 09:48:33)
[Clang 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sys import getsizeof
>>> getsizeof([0] * 10)
144
>>> getsizeof(list([0] * 10))
200
>>> getsizeof(list(range(10)))
200

----------
components: Interpreter Core
messages: 315006
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Improve list() pre-sizing for inputs with known lengths
type: performance
versions: Python 3.8

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

Reply via email to