[Python-ideas] Length hinting and preallocation for container types
Christian Heimes
christian at python.org
Tue Mar 5 19:55:32 CET 2013
Am 05.03.2013 18:10, schrieb Antoine Pitrou:
> So how about benchmark numbers?
The speedup is smallish:
$ ./python -m timeit -n1000 "l = []" "l.__preallocate__(10000)" "app =
l.append" "for i in range(10000): app(i)" "l.__shrink__()"
1000 loops, best of 3: 3.68 msec per loop
$ ./python -m timeit -n1000 "l = []" "app = l.append" "for i in
range(10000): app(i)"
1000 loops, best of 3: 3.75 msec per loop
More information about the Python-ideas
mailing list