[pypy-commit] pypy simple-range-strategy: use tuple for storage
squeaky
noreply at buildbot.pypy.org
Tue Mar 4 18:52:20 CET 2014
Author: Squeaky <squeaky_pl at gmx.com>
Branch: simple-range-strategy
Changeset: r69673:16d6e5eb5c28
Date: 2014-03-04 11:18 +0100
http://bitbucket.org/pypy/pypy/changeset/16d6e5eb5c28/
Log: use tuple for storage
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
@@ -45,7 +45,7 @@
storage = strategy.erase(None)
elif start == 0 and step == 1 and length <= 2 ** 31 - 1:
strategy = space.fromcache(SimpleRangeListStrategy)
- storage = strategy.erase(length)
+ storage = strategy.erase((length,))
else:
strategy = space.fromcache(RangeListStrategy)
storage = strategy.erase((start, step, length))
@@ -1041,7 +1041,7 @@
return self._getitems_range(w_list, True)
def getstorage_copy(self, w_list):
- # tuple/int is immutable
+ # tuple is immutable
return w_list.lstorage
@jit.dont_look_inside
@@ -1094,8 +1094,8 @@
class SimpleRangeListStrategy(BaseRangeListStrategy):
"""SimpleRangeListStrategy is used when a list is created using the range
- method providing only positive length. The storage is a positive integer
- less than 2**31 - 1 storing length."""
+ method providing only positive length. The storage is a one element tuple
+ with positive integer less than 2**31 - 1 storing length."""
_applevel_repr = "simple_range"
@@ -1106,7 +1106,7 @@
def find(self, w_list, w_obj, startindex, stopindex):
if type(w_obj) is W_IntObject:
obj = self.unwrap(w_obj)
- length = self.unerase(w_list.lstorage)
+ length = self.unerase(w_list.lstorage)[0]
if 0 <= obj < length and startindex <= obj < stopindex:
return obj
else:
@@ -1114,7 +1114,7 @@
return ListStrategy.find(self, w_list, w_obj, startindex, stopindex)
def length(self, w_list):
- return self.unerase(w_list.lstorage)
+ return self.unerase(w_list.lstorage)[0]
def _getitem_unwrapped(self, w_list, i):
length = self.unerase(w_list.lstorage)
@@ -1125,7 +1125,7 @@
@specialize.arg(2)
def _getitems_range(self, w_list, wrap_items):
- length = self.unerase(w_list.lstorage)
+ length = self.unerase(w_list.lstorage)[0]
if wrap_items:
r = [None] * length
else:
@@ -1144,9 +1144,9 @@
func_with_new_name(_getitems_range, "_getitems_range_unroll"))
def pop_end(self, w_list):
- length_m1 = self.unerase(w_list.lstorage) - 1
+ length_m1 = self.unerase(w_list.lstorage)[0] - 1
w_result = self.wrap(length_m1)
- w_list.lstorage = self.erase(length_m1)
+ w_list.lstorage = self.erase((length_m1,))
return w_result
def pop(self, w_list, index):
diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py
--- a/pypy/objspace/std/test/test_liststrategies.py
+++ b/pypy/objspace/std/test/test_liststrategies.py
@@ -418,7 +418,6 @@
assert isinstance(l.strategy, SimpleRangeListStrategy)
v = l.pop(0)
assert self.space.eq_w(v, self.space.wrap(0))
- # XXX promote to RangeListStrategy
assert isinstance(l.strategy, IntegerListStrategy)
l = make_range_list(self.space, 0, 1, 10)
More information about the pypy-commit
mailing list