Author: Armin Rigo <[email protected]>
Branch: cpyext-gc-support-2
Changeset: r82235:52cda7675796
Date: 2016-02-14 11:42 +0100
http://bitbucket.org/pypy/pypy/changeset/52cda7675796/
Log: oops, W_ListObject.switch_to_object_strategy() will always make an
internal copy, even if the strategy is already 'object'.
diff --git a/pypy/module/cpyext/listobject.py b/pypy/module/cpyext/listobject.py
--- a/pypy/module/cpyext/listobject.py
+++ b/pypy/module/cpyext/listobject.py
@@ -49,7 +49,7 @@
if index < 0 or index >= w_list.length():
raise OperationError(space.w_IndexError, space.wrap(
"list index out of range"))
- w_list.switch_to_object_strategy() # make sure we can return a borrowed
obj
+ w_list.ensure_object_strategy() # make sure we can return a borrowed obj
# XXX ^^^ how does this interact with CPyListStrategy?
return w_list.getitem(index)
diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py
--- a/pypy/module/cpyext/sequence.py
+++ b/pypy/module/cpyext/sequence.py
@@ -45,7 +45,7 @@
if isinstance(w_obj, listobject.W_ListObject):
# make sure we can return a borrowed obj from PySequence_Fast_GET_ITEM
# XXX how does this interact with CPyListStrategy?
- w_obj.switch_to_object_strategy()
+ w_obj.ensure_object_strategy()
return w_obj
if isinstance(w_obj, tupleobject.W_TupleObject):
return w_obj
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
@@ -222,6 +222,10 @@
self.strategy = object_strategy
object_strategy.init_from_list_w(self, list_w)
+ def ensure_object_strategy(self): # for cpyext
+ if self.strategy is not self.space.fromcache(ObjectListStrategy):
+ self.switch_to_object_strategy()
+
def _temporarily_as_objects(self):
if self.strategy is self.space.fromcache(ObjectListStrategy):
return self
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit