[pypy-svn] r14603 - pypy/branch/pypy-translation-snapshot/objspace/std

arigo at codespeak.net arigo at codespeak.net
Wed Jul 13 01:09:27 CEST 2005


Author: arigo
Date: Wed Jul 13 01:09:26 2005
New Revision: 14603

Modified:
   pypy/branch/pypy-translation-snapshot/objspace/std/listobject.py
Log:
Merge rev 14602 from the trunk.


Modified: pypy/branch/pypy-translation-snapshot/objspace/std/listobject.py
==============================================================================
--- pypy/branch/pypy-translation-snapshot/objspace/std/listobject.py	(original)
+++ pypy/branch/pypy-translation-snapshot/objspace/std/listobject.py	Wed Jul 13 01:09:26 2005
@@ -271,7 +271,9 @@
             items[j-slicelength] = items[j]            
             j += 1
         # make sure entries after ob_size are None, to avoid keeping references
-        w_list.ob_size -= slicelength
+        n -= slicelength
+        assert n >= 0            # annotator hint
+        w_list.ob_size = n
         for i in range(w_list.ob_size, n):
             items[i] = None
         # now we can destruct recycle safely, regardless of
@@ -465,26 +467,29 @@
 
 def _del_slice(w_list, ilow, ihigh):
     """ similar to the deletion part of list_ass_slice in CPython """
+    n = w_list.ob_size
     if ilow < 0:
         ilow = 0
-    elif ilow > w_list.ob_size:
-        ilow = w_list.ob_size
+    elif ilow > n:
+        ilow = n
     if ihigh < ilow:
         ihigh = ilow
-    elif ihigh > w_list.ob_size:
-        ihigh = w_list.ob_size
+    elif ihigh > n:
+        ihigh = n
     items = w_list.ob_item
     d = ihigh-ilow
     # keep a reference to the objects to be removed,
     # preventing side effects during destruction
     recycle = [items[i] for i in range(ilow, ihigh)]
-    for i in range(ilow, w_list.ob_size - d):
+    for i in range(ilow, n - d):
         items[i] = items[i+d]
         items[i+d] = None
     # make sure entries after ob_size-d are None, to avoid keeping references
     # (the above loop already set to None all items[ilow+d:old_style])
-    w_list.ob_size -= d
-    for i in range(w_list.ob_size, ilow + d):
+    n -= d
+    assert n >= 0            # annotator hint
+    w_list.ob_size = n
+    for i in range(n, ilow + d):
         items[i] = None
     # now we can destruct recycle safely, regardless of
     # side-effects to the list



More information about the Pypy-commit mailing list