[Python-ideas] Length hinting and preallocation for container types
steve at pearwood.info
Fri Mar 8 17:37:13 CET 2013
On 09/03/13 00:27, Eli Bendersky wrote:
> If it's voting time, I'm -1. Having programmed a lot of memory-constrained
> systems (not in Python, though) - this is not how things usually work
> there. In a memory-constrained system, you don't "grow and shrink" your
> data structures. That's because growing often needs to reallocate the whole
> chunk and do a copy, and shrinking only helps memory fragmentation. In such
> systems, you usually know in advance or at least limit the size of data
> structures and pre-allocate, which is perfectly possible in Python today.
Are you referring to using (say) [None]*n, for some size n?
Is this a language guarantee that it won't over-allocate, or just an accident
More information about the Python-ideas