[pypy-commit] pypy remove-tuple-smm: Use space.isinstance_w(x, space.w_tuple) instead of isinstance(x, W_AbstractTupleObject).

Manuel Jacob noreply at buildbot.pypy.org
Wed May 22 12:19:17 CEST 2013


Author: Manuel Jacob
Branch: remove-tuple-smm
Changeset: r64440:463087e7703f
Date: 2013-05-22 12:17 +0200
http://bitbucket.org/pypy/pypy/changeset/463087e7703f/

Log:	Use space.isinstance_w(x, space.w_tuple) instead of isinstance(x,
	W_AbstractTupleObject).

diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -14,7 +14,6 @@
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
 from pypy.objspace.std.stringobject import W_StringObject
-from pypy.objspace.std.tupleobject import W_AbstractTupleObject
 from pypy.objspace.std.unicodeobject import W_UnicodeObject
 from pypy.objspace.std.util import get_positive_index
 from rpython.rlib.rstring import StringBuilder
@@ -310,10 +309,10 @@
                                                          w_start, w_stop)
 
 def str_startswith__Bytearray_ANY_ANY_ANY(space, w_bytearray, w_prefix, w_start, w_stop):
-    if isinstance(w_prefix, W_AbstractTupleObject):
+    if space.isinstance_w(w_prefix, space.w_tuple):
         w_str = str__Bytearray(space, w_bytearray)
         w_prefix = space.newtuple([space.wrap(space.bufferstr_new_w(w_entry)) for w_entry in
-                                   space.unpackiterable(w_prefix)])
+                                   space.fixedview(w_prefix)])
         return stringobject.str_startswith__String_ANY_ANY_ANY(space, w_str, w_prefix,
                                                                   w_start, w_stop)
 
@@ -323,10 +322,10 @@
                                                               w_start, w_stop)
 
 def str_endswith__Bytearray_ANY_ANY_ANY(space, w_bytearray, w_suffix, w_start, w_stop):
-    if isinstance(w_suffix, W_AbstractTupleObject):
+    if space.isinstance_w(w_suffix, space.w_tuple):
         w_str = str__Bytearray(space, w_bytearray)
         w_suffix = space.newtuple([space.wrap(space.bufferstr_new_w(w_entry)) for w_entry in
-                                   space.unpackiterable(w_suffix)])
+                                   space.fixedview(w_suffix)])
         return stringobject.str_endswith__String_ANY_ANY_ANY(space, w_str, w_suffix,
                                                                   w_start, w_stop)
     w_suffix = space.wrap(space.bufferstr_new_w(w_suffix))
diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -12,7 +12,6 @@
 from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
 from pypy.objspace.std.stringtype import (
     joined2, sliced, stringendswith, stringstartswith, wrapchar, wrapstr)
-from pypy.objspace.std.tupleobject import W_AbstractTupleObject
 from rpython.rlib import jit
 from rpython.rlib.objectmodel import (
     compute_hash, compute_unique_id, specialize)
@@ -685,7 +684,7 @@
     return space.newbool(stringendswith(u_self, w_suffix._value, start, end))
 
 def str_endswith__String_ANY_ANY_ANY(space, w_self, w_suffixes, w_start, w_end):
-    if not isinstance(w_suffixes, W_AbstractTupleObject):
+    if not space.isinstance_w(w_suffixes, space.w_tuple):
         raise FailedToImplement
     (u_self, start, end) = _convert_idx_params(space, w_self, w_start,
                                                w_end, True)
@@ -705,7 +704,7 @@
     return space.newbool(stringstartswith(u_self, w_prefix._value, start, end))
 
 def str_startswith__String_ANY_ANY_ANY(space, w_self, w_prefixes, w_start, w_end):
-    if not isinstance(w_prefixes, W_AbstractTupleObject):
+    if not space.isinstance_w(w_prefixes, space.w_tuple):
         raise FailedToImplement
     (u_self, start, end) = _convert_idx_params(space, w_self,
                                                w_start, w_end, True)
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -12,7 +12,6 @@
     W_StringObject, make_rsplit_with_delim)
 from pypy.objspace.std.stringtype import stringendswith, stringstartswith
 from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.tupleobject import W_AbstractTupleObject
 from rpython.rlib import jit
 from rpython.rlib.rarithmetic import ovfcheck
 from rpython.rlib.objectmodel import (
@@ -503,7 +502,7 @@
 
 def unicode_startswith__Unicode_ANY_ANY_ANY(space, w_unistr, w_prefixes,
                                               w_start, w_end):
-    if not isinstance(w_prefixes, W_AbstractTupleObject):
+    if not space.isinstance_w(w_prefixes, space.w_tuple):
         raise FailedToImplement
     unistr, start, end = _convert_idx_params(space, w_unistr,
                                              w_start, w_end, True)
@@ -515,7 +514,7 @@
 
 def unicode_endswith__Unicode_ANY_ANY_ANY(space, w_unistr, w_suffixes,
                                             w_start, w_end):
-    if not isinstance(w_suffixes, W_AbstractTupleObject):
+    if not space.isinstance_w(w_suffixes, space.w_tuple):
         raise FailedToImplement
     unistr, start, end = _convert_idx_params(space, w_unistr,
                                              w_start, w_end, True)


More information about the pypy-commit mailing list