Christian Heimes added the comment:

Here is an experimental patch. The speedup is ... measurable.

$ ./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

----------
keywords: +patch
Added file: http://bugs.python.org/file29315/preallocate.patch

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

Reply via email to