[pypy-commit] pypy default: merge
fijal
noreply at buildbot.pypy.org
Wed Oct 9 16:01:00 CEST 2013
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r67243:01608017108a
Date: 2013-10-09 15:03 +0200
http://bitbucket.org/pypy/pypy/changeset/01608017108a/
Log: merge
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
@@ -30,7 +30,7 @@
from rpython.rlib import debug, jit, rerased
from rpython.rlib.listsort import make_timsort_class
from rpython.rlib.objectmodel import (
- instantiate, newlist_hint, resizelist_hint, specialize)
+ instantiate, newlist_hint, resizelist_hint, specialize, import_from_mixin)
from rpython.tool.sourcetools import func_with_new_name
__all__ = ['W_ListObject', 'make_range_list', 'make_empty_list_with_size']
@@ -1170,7 +1170,6 @@
class AbstractUnwrappedStrategy(object):
- _mixin_ = True
def wrap(self, unwrapped):
raise NotImplementedError
@@ -1329,7 +1328,6 @@
def setslice(self, w_list, start, step, slicelength, w_other):
assert slicelength >= 0
- items = self.unerase(w_list.lstorage)
if self is self.space.fromcache(ObjectListStrategy):
w_other = w_other._temporarily_as_objects()
@@ -1341,6 +1339,7 @@
w_list.setslice(start, step, slicelength, w_other_as_object)
return
+ items = self.unerase(w_list.lstorage)
oldsize = len(items)
len2 = w_other.length()
if step == 1: # Support list resizing for non-extended slices
@@ -1456,7 +1455,9 @@
self.unerase(w_list.lstorage).reverse()
-class ObjectListStrategy(AbstractUnwrappedStrategy, ListStrategy):
+class ObjectListStrategy(ListStrategy):
+ import_from_mixin(AbstractUnwrappedStrategy)
+
_none_value = None
_applevel_repr = "object"
@@ -1489,7 +1490,9 @@
return self.unerase(w_list.lstorage)
-class IntegerListStrategy(AbstractUnwrappedStrategy, ListStrategy):
+class IntegerListStrategy(ListStrategy):
+ import_from_mixin(AbstractUnwrappedStrategy)
+
_none_value = 0
_applevel_repr = "int"
@@ -1520,7 +1523,30 @@
return self.unerase(w_list.lstorage)
-class FloatListStrategy(AbstractUnwrappedStrategy, ListStrategy):
+ _base_extend_from_list = _extend_from_list
+
+ def _extend_from_list(self, w_list, w_other):
+ if w_other.strategy is self.space.fromcache(RangeListStrategy):
+ l = self.unerase(w_list.lstorage)
+ other = w_other.getitems_int()
+ assert other is not None
+ l += other
+ return
+ return self._base_extend_from_list(w_list, w_other)
+
+
+ _base_setslice = setslice
+
+ def setslice(self, w_list, start, step, slicelength, w_other):
+ if w_other.strategy is self.space.fromcache(RangeListStrategy):
+ storage = self.erase(w_other.getitems_int())
+ w_other = W_ListObject.from_storage_and_strategy(
+ self.space, storage, self)
+ return self._base_setslice(w_list, start, step, slicelength, w_other)
+
+class FloatListStrategy(ListStrategy):
+ import_from_mixin(AbstractUnwrappedStrategy)
+
_none_value = 0.0
_applevel_repr = "float"
@@ -1548,7 +1574,9 @@
l.reverse()
-class StringListStrategy(AbstractUnwrappedStrategy, ListStrategy):
+class StringListStrategy(ListStrategy):
+ import_from_mixin(AbstractUnwrappedStrategy)
+
_none_value = None
_applevel_repr = "str"
@@ -1579,7 +1607,9 @@
return self.unerase(w_list.lstorage)
-class UnicodeListStrategy(AbstractUnwrappedStrategy, ListStrategy):
+class UnicodeListStrategy(ListStrategy):
+ import_from_mixin(AbstractUnwrappedStrategy)
+
_none_value = None
_applevel_repr = "unicode"
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
@@ -225,6 +225,15 @@
l.setslice(0, 1, 2, W_ListObject(space, [w('a'), w(2), w(3)]))
assert isinstance(l.strategy, ObjectListStrategy)
+ def test_setslice_int_range(self):
+ space = self.space
+ w = space.wrap
+ l = W_ListObject(space, [w(1), w(2), w(3)])
+ assert isinstance(l.strategy, IntegerListStrategy)
+ l.setslice(0, 1, 2, make_range_list(space, 5, 1, 4))
+ assert isinstance(l.strategy, IntegerListStrategy)
+
+
def test_setslice_List(self):
space = self.space
@@ -467,6 +476,12 @@
l4 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
assert self.space.eq_w(l3, l4)
+ def test_add_of_range_and_int(self):
+ l1 = make_range_list(self.space, 0, 1, 100)
+ l2 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
+ l3 = self.space.add(l2, l1)
+ assert l3.strategy is l2.strategy
+
def test_mul(self):
l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
l2 = l1.mul(2)
More information about the pypy-commit
mailing list