[pypy-svn] rev 583 - pypy/trunk/src/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Tue May 27 17:14:18 CEST 2003


Author: arigo
Date: Tue May 27 17:14:17 2003
New Revision: 583

Modified:
   pypy/trunk/src/pypy/objspace/std/listobject.py
   pypy/trunk/src/pypy/objspace/std/tupleobject.py
Log:
pre-allocating memory for slicing

Modified: pypy/trunk/src/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/listobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/listobject.py	Tue May 27 17:14:17 2003
@@ -54,9 +54,9 @@
     step        = space.unwrap(w_step)
     slicelength = space.unwrap(w_slicelength)
     assert slicelength >= 0
-    subitems = []
+    subitems = [None] * slicelength
     for i in range(slicelength):
-        subitems.append(items[start])
+        subitems[i] = items[start]
         start += step
     return W_ListObject(subitems)
 

Modified: pypy/trunk/src/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/tupleobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/tupleobject.py	Tue May 27 17:14:17 2003
@@ -50,9 +50,9 @@
     step        = space.unwrap(w_step)
     slicelength = space.unwrap(w_slicelength)
     assert slicelength >= 0
-    subitems = []
+    subitems = [None] * slicelength
     for i in range(slicelength):
-        subitems.append(items[start])
+        subitems[i] = items[start]
         start += step
     return W_TupleObject(subitems)
 


More information about the Pypy-commit mailing list