The REALLY bad thing about Python lists ..
jkraska1 at san.rr.com
Tue May 16 01:47:32 EDT 2000
> Python deliberately overallocates by a small amount; this is a deliberate
> optimization for the cases Moshe identified; it works very well.
BTW, for those who are interested, but don't have the time to
look, here is the actual behavior:
#define ROUNDUP(n, PyTryBlock) \
static int roundupsize(n)
if (n < 500) return ROUNDUP(n, 10);
else return ROUNDUP(n, 100);
I'm curious, looking at this, why we're not able to access
the initial sizes and growth rates directly? While such
needs are rare, and therefore shouldn't be added syntatic
weight for the everyday user, I'd think there would be
some benefit in allowing the complexity fiends some level
of access with relatively little cost (is the extra overhead
of keeping a growth rate attribute on the vector structure
a burden? come now).
More information about the Python-list