[pypy-svn] r17603 - pypy/dist/pypy/rpython
arigo at codespeak.net
arigo at codespeak.net
Fri Sep 16 21:15:30 CEST 2005
Author: arigo
Date: Fri Sep 16 21:15:25 2005
New Revision: 17603
Modified:
pypy/dist/pypy/rpython/rlist.py
Log:
This may be a good speed-up (untested): don't reallocate small lists too often
when items are removed. This formula should make sure that e.g. popping from
2 to 1 doesn't reallocate from 4 to 4 (!). It might have the side effect that
small lists with elements removed consume a tiny bit more memory, but well.
Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py (original)
+++ pypy/dist/pypy/rpython/rlist.py Fri Sep 16 21:15:25 2005
@@ -341,7 +341,7 @@
# Bypass realloc() when a previous overallocation is large enough
# to accommodate the newsize. If the newsize falls lower than half
# the allocated size, then proceed with the realloc() to shrink the list.
- if allocated >= newsize and newsize >= (allocated >> 1):
+ if allocated >= newsize and newsize >= ((allocated >> 1) - 5):
# assert l.ob_item != NULL or newsize == 0
l.length = newsize
return
More information about the Pypy-commit
mailing list