Author: Squeaky <[email protected]>
Branch: simple-range-strategy
Changeset: r69671:8d005ad2deff
Date: 2014-03-03 21:02 +0100
http://bitbucket.org/pypy/pypy/changeset/8d005ad2deff/

Log:    make range now uses SimpeRangeListStrategy

diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -43,6 +43,9 @@
     if length <= 0:
         strategy = space.fromcache(EmptyListStrategy)
         storage = strategy.erase(None)
+    elif start == 0 and step == 1 and length <= 2 ** 31 - 1:
+        strategy = space.fromcache(SimpleRangeListStrategy)
+        storage = strategy.erase(length)
     else:
         strategy = space.fromcache(RangeListStrategy)
         storage = strategy.erase((start, step, length))
@@ -1084,6 +1087,7 @@
         w_list.extend(w_any)
 
     def reverse(self, w_list):
+        # XXX this could be specialized for SimpleRange to promote to Range
         self.switch_to_integer_strategy(w_list)
         w_list.reverse()
 
@@ -1129,9 +1133,9 @@
         i = 0
         while i < length:
             if wrap_items:
-                r[n] = self.wrap(i)
+                r[i] = self.wrap(i)
             else:
-                r[n] = i
+                r[i] = i
             i += 1
 
         return r
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to