[pypy-svn] r58275 - in pypy/branch/tuple-nonresizable-395/pypy: interpreter interpreter/astcompiler interpreter/test module/__builtin__ module/__builtin__/test module/_codecs module/_rawffi module/_stackless/test objspace/flow objspace/std
fijal at codespeak.net
fijal at codespeak.net
Sat Sep 20 17:52:38 CEST 2008
Author: fijal
Date: Sat Sep 20 17:52:36 2008
New Revision: 58275
Removed:
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/seqinterface.py
Modified:
pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/pyassem.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/baseobjspace.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/gateway.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/interactive.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/nestedscope.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyopcode.py
pypy/branch/tuple-nonresizable-395/pypy/interpreter/test/test_objspace.py
pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/abstractinst.py
pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/compiling.py
pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/interp_classobj.py
pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/test/test_abstractinst.py
pypy/branch/tuple-nonresizable-395/pypy/module/_codecs/interp_codecs.py
pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/interp_rawffi.py
pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/structure.py
pypy/branch/tuple-nonresizable-395/pypy/module/_stackless/test/test_frame_chain_reconstruction.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/flow/objspace.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/listobject.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/marshal_impl.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/objspace.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeobject.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeunicodeobject.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/stringobject.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/strsliceobject.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/tupleobject.py
pypy/branch/tuple-nonresizable-395/pypy/objspace/std/unicodeobject.py
Log:
* remove seqinterface.py as it's not needed any more
* remove space.unpacktuple, use space.viewiterable
* add objspace.unpackiterable shortcuts
* remove segfault from unpacktuple (by removing it)
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/pyassem.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/pyassem.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/astcompiler/pyassem.py Sat Sep 20 17:52:36 2008
@@ -390,7 +390,7 @@
l_w = [None] * len(keys_w)
for w_key in keys_w:
index = space.int_w(space.getitem(self.w_consts, w_key))
- w_v = space.unpacktuple(w_key)[0]
+ w_v = space.viewiterable(w_key)[0]
l_w[index] = w_v
return l_w
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/baseobjspace.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/baseobjspace.py Sat Sep 20 17:52:36 2008
@@ -665,17 +665,6 @@
return make_sure_not_resized(self.unpackiterable(w_iterable,
expected_length)[:])
- def unpacktuple(self, w_tuple, expected_length=-1):
- """Same as unpackiterable(), but only for tuples.
- Only use for bootstrapping or performance reasons."""
- tuple_length = self.int_w(self.len(w_tuple))
- if expected_length != -1 and tuple_length != expected_length:
- raise UnpackValueError("got a tuple of length %d instead of %d" % (
- tuple_length, expected_length))
- items = [
- self.getitem(w_tuple, self.wrap(i)) for i in range(tuple_length)]
- return items
-
def exception_match(self, w_exc_type, w_check_class):
"""Checks if the given exception type matches 'w_check_class'."""
if self.is_w(w_exc_type, w_check_class):
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/gateway.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/gateway.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/gateway.py Sat Sep 20 17:52:36 2008
@@ -207,7 +207,7 @@
% (self.scopenext(), self.scopenext()))
def visit_args_w(self, el):
- self.run_args.append("space.unpacktuple(%s)" % self.scopenext())
+ self.run_args.append("space.viewiterable(%s)" % self.scopenext())
def visit_w_args(self, el):
self.run_args.append(self.scopenext())
@@ -406,7 +406,7 @@
# baseobjspace.W_Root is for wrapped arguments to keep wrapped
# baseobjspace.Wrappable subclasses imply interp_w and a typecheck
# argument.Arguments is for a final rest arguments Arguments object
- # 'args_w' for unpacktuple applied to rest arguments
+ # 'args_w' for viewiterable applied to rest arguments
# 'w_args' for rest arguments passed as wrapped tuple
# str,int,float: unwrap argument as such type
# (function, cls) use function to check/unwrap argument of type cls
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/interactive.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/interactive.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/interactive.py Sat Sep 20 17:52:36 2008
@@ -73,7 +73,7 @@
words = self.get_words(w_clz)
try:
w_bases = s.getattr(w_clz, s.wrap("__bases__"))
- bases_w = s.unpacktuple(w_bases)
+ bases_w = s.viewiterable(w_bases)
except error.OperationError:
return words
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/nestedscope.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/nestedscope.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/nestedscope.py Sat Sep 20 17:52:36 2008
@@ -202,7 +202,7 @@
if codeobj.magic >= 0xa0df281: # CPython 2.5 AST branch merge
w_freevarstuple = f.popvalue()
freevars = [f.space.interp_w(Cell, cell)
- for cell in f.space.unpacktuple(w_freevarstuple)]
+ for cell in f.space.viewiterable(w_freevarstuple)]
else:
nfreevars = len(codeobj.co_freevars)
freevars = [f.space.interp_w(Cell, f.popvalue())
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyopcode.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyopcode.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/pyopcode.py Sat Sep 20 17:52:36 2008
@@ -551,7 +551,7 @@
w_compile_flags,
f.space.wrap(f.get_builtin()),
f.space.gettypeobject(PyCode.typedef))
- w_prog, w_globals, w_locals = f.space.unpacktuple(w_resulttuple, 3)
+ w_prog, w_globals, w_locals = f.space.viewiterable(w_resulttuple, 3)
plain = f.w_locals is not None and f.space.is_w(w_locals, f.w_locals)
if plain:
Modified: pypy/branch/tuple-nonresizable-395/pypy/interpreter/test/test_objspace.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/interpreter/test/test_objspace.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/interpreter/test/test_objspace.py Sat Sep 20 17:52:36 2008
@@ -54,14 +54,14 @@
raises(ValueError, self.space.unpackiterable, w_l, 3)
raises(ValueError, self.space.unpackiterable, w_l, 5)
- def test_unpacktuple(self):
+ def test_viewiterable(self):
w = self.space.wrap
l = [w(1), w(2), w(3), w(4)]
w_l = self.space.newtuple(l)
- assert self.space.unpacktuple(w_l) == l
- assert self.space.unpacktuple(w_l, 4) == l
- raises(ValueError, self.space.unpacktuple, w_l, 3)
- raises(ValueError, self.space.unpacktuple, w_l, 5)
+ assert self.space.viewiterable(w_l) == l
+ assert self.space.viewiterable(w_l, 4) == l
+ raises(ValueError, self.space.viewiterable, w_l, 3)
+ raises(ValueError, self.space.viewiterable, w_l, 5)
def test_exception_match(self):
assert self.space.exception_match(self.space.w_ValueError,
@@ -203,7 +203,7 @@
w_res = space.call_obj_args(w_f, w_9, Arguments(space, [w_1]))
- w_x, w_y = space.unpacktuple(w_res, 2)
+ w_x, w_y = space.viewiterable(w_res, 2)
assert w_x is w_9
assert w_y is w_1
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/abstractinst.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/abstractinst.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/abstractinst.py Sat Sep 20 17:52:36 2008
@@ -79,7 +79,7 @@
# -- case (anything, tuple)
if space.is_true(space.isinstance(w_klass_or_tuple, space.w_tuple)):
- for w_klass in space.unpacktuple(w_klass_or_tuple):
+ for w_klass in space.viewiterable(w_klass_or_tuple):
if abstract_isinstance_w(space, w_obj, w_klass):
return True
return False
@@ -104,7 +104,7 @@
return True
w_bases = _get_bases(space, w_derived)
if w_bases is not None:
- for w_base in space.unpacktuple(w_bases):
+ for w_base in space.viewiterable(w_bases):
if _issubclass_recurse(space, w_base, w_top):
return True
return False
@@ -134,7 +134,7 @@
# -- case (class-like-object, tuple-of-classes)
if space.is_true(space.isinstance(w_klass_or_tuple, space.w_tuple)):
- for w_klass in space.unpacktuple(w_klass_or_tuple):
+ for w_klass in space.viewiterable(w_klass_or_tuple):
if abstract_issubclass_w(space, w_derived, w_klass):
return True
return False
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/compiling.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/compiling.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/compiling.py Sat Sep 20 17:52:36 2008
@@ -67,9 +67,9 @@
"<string>", "eval")
except OperationError, e:
if e.match(space, space.w_SyntaxError):
- e_value_w = space.unpacktuple(e.w_value)
+ e_value_w = space.viewiterable(e.w_value)
if len(e_value_w) == 2:
- e_loc_w = space.unpacktuple(e_value_w[1])
+ e_loc_w = space.viewiterable(e_value_w[1])
e.w_value = space.newtuple([e_value_w[0],
space.newtuple([space.w_None]+
e_loc_w[1:])])
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/interp_classobj.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/interp_classobj.py Sat Sep 20 17:52:36 2008
@@ -280,7 +280,7 @@
if not e.match(space, space.w_TypeError):
raise
return [None, None]
- return space.unpacktuple(w_tup, 2)
+ return space.viewiterable(w_tup, 2)
def descr_instance_new(space, w_type, w_class, w_dict=None):
# w_type is not used at all
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/test/test_abstractinst.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/test/test_abstractinst.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/__builtin__/test/test_abstractinst.py Sat Sep 20 17:52:36 2008
@@ -5,7 +5,7 @@
def test_abstract_isclass(self):
space = self.space
- w_B1, w_B2, w_B3, w_X, w_Y = space.unpacktuple(space.appexec([], """():
+ w_B1, w_B2, w_B3, w_X, w_Y = space.viewiterable(space.appexec([], """():
class X(object): pass
class Y: pass
B1, B2, B3 = X(), X(), X()
@@ -22,7 +22,7 @@
def test_abstract_getclass(self):
space = self.space
- w_x, w_y, w_A, w_MyInst = space.unpacktuple(space.appexec([], """():
+ w_x, w_y, w_A, w_MyInst = space.viewiterable(space.appexec([], """():
class MyInst(object):
def __init__(self, myclass):
self.myclass = myclass
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/_codecs/interp_codecs.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/_codecs/interp_codecs.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/_codecs/interp_codecs.py Sat Sep 20 17:52:36 2008
@@ -35,7 +35,7 @@
space.wrap("encoding error handler must return "
"(unicode, int) tuple, not %s" % (
space.str_w(space.repr(w_res)))))
- w_replace, w_newpos = space.unpacktuple(w_res, 2)
+ w_replace, w_newpos = space.viewiterable(w_res, 2)
newpos = space.int_w(w_newpos)
if (newpos < 0):
newpos = len(input) + newpos
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/interp_rawffi.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/interp_rawffi.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/interp_rawffi.py Sat Sep 20 17:52:36 2008
@@ -98,7 +98,7 @@
resshape = cache.get_array_type(letter2tp(space, letter))
else:
letter = 'V'
- w_shapetype, w_length = space.unpacktuple(w_shape, expected_length=2)
+ w_shapetype, w_length = space.viewiterable(w_shape, expected_length=2)
from pypy.module._rawffi.structure import W_Structure
resshape = space.interp_w(W_Structure, w_shapetype)
ffi_type = resshape.get_ffi_type()
@@ -109,7 +109,7 @@
letter = space.str_w(w_shape)
return letter2tp(space, letter)
else:
- w_shapetype, w_length = space.unpacktuple(w_shape, expected_length=2)
+ w_shapetype, w_length = space.viewiterable(w_shape, expected_length=2)
resshape = space.interp_w(W_DataShape, w_shapetype)
length = space.int_w(w_length)
size, alignment = resshape._size_alignment()
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/structure.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/structure.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/_rawffi/structure.py Sat Sep 20 17:52:36 2008
@@ -119,7 +119,7 @@
def descr_new_structure(space, w_type, w_shapeinfo):
if space.is_true(space.isinstance(w_shapeinfo, space.w_tuple)):
- w_size, w_alignment = space.unpacktuple(w_shapeinfo, expected_length=2)
+ w_size, w_alignment = space.viewiterable(w_shapeinfo, expected_length=2)
S = W_Structure(space, None, space.int_w(w_size),
space.int_w(w_alignment))
else:
Modified: pypy/branch/tuple-nonresizable-395/pypy/module/_stackless/test/test_frame_chain_reconstruction.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/module/_stackless/test/test_frame_chain_reconstruction.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/module/_stackless/test/test_frame_chain_reconstruction.py Sat Sep 20 17:52:36 2008
@@ -92,7 +92,7 @@
return co, f, g
""")
- w_co, w_f, w_g = space.unpacktuple(w_res)
+ w_co, w_f, w_g = space.viewiterable(w_res)
ec = space.getexecutioncontext()
fcode = w_f.code.co_code
@@ -151,7 +151,7 @@
return co, f, g
""")
- w_co, w_f, w_g = space.unpacktuple(w_res)
+ w_co, w_f, w_g = space.viewiterable(w_res)
ec = space.getexecutioncontext()
fcode = w_f.code.co_code
@@ -223,7 +223,7 @@
return co, f, g
""")
- w_co, w_f, w_g = space.unpacktuple(w_res)
+ w_co, w_f, w_g = space.viewiterable(w_res)
ec = space.getexecutioncontext()
fcode = w_f.code.co_code
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/flow/objspace.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/flow/objspace.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/flow/objspace.py Sat Sep 20 17:52:36 2008
@@ -202,7 +202,7 @@
# the simple case
return ObjSpace.exception_match(self, w_exc_type, w_check_class)
# checking a tuple of classes
- for w_klass in self.unpacktuple(w_check_class):
+ for w_klass in self.viewiterable(w_check_class):
if ObjSpace.exception_match(self, w_exc_type, w_klass):
return True
return False
@@ -264,12 +264,7 @@
checkgraph(graph)
return graph
- def unpacktuple(self, w_tuple, expected_length=None):
-## # special case to accept either Constant tuples
-## # or real tuples of Variables/Constants
-## if isinstance(w_tuple, tuple):
-## result = w_tuple
-## else:
+ def viewiterable(self, w_tuple, expected_length=None):
unwrapped = self.unwrap(w_tuple)
result = tuple([Constant(x) for x in unwrapped])
if expected_length is not None and len(result) != expected_length:
@@ -286,26 +281,6 @@
if isinstance(w_iterable, Variable) and expected_length is None:
raise UnwrapException, ("cannot unpack a Variable iterable"
"without knowing its length")
-## # XXX TEMPORARY HACK XXX TEMPORARY HACK XXX TEMPORARY HACK
-## print ("*** cannot unpack a Variable iterable "
-## "without knowing its length,")
-## print " assuming a list or tuple with up to 7 items"
-## items = []
-## w_len = self.len(w_iterable)
-## i = 0
-## while True:
-## w_i = self.wrap(i)
-## w_cond = self.eq(w_len, w_i)
-## if self.is_true(w_cond):
-## break # done
-## if i == 7:
-## # too many values
-## raise OperationError(self.w_AssertionError, self.w_None)
-## w_item = self.do_operation('getitem', w_iterable, w_i)
-## items.append(w_item)
-## i += 1
-## return items
-## # XXX TEMPORARY HACK XXX TEMPORARY HACK XXX TEMPORARY HACK
elif expected_length is not None:
w_len = self.len(w_iterable)
w_correct = self.eq(w_len, self.wrap(expected_length))
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/listobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/listobject.py Sat Sep 20 17:52:36 2008
@@ -2,14 +2,12 @@
from pypy.objspace.std.inttype import wrapint
from pypy.objspace.std.listtype import get_list_index
from pypy.objspace.std.sliceobject import W_SliceObject
-from pypy.objspace.std.seqinterface import W_SeqObject
from pypy.objspace.std import slicetype
from pypy.interpreter import gateway, baseobjspace
from pypy.rlib.listsort import TimSort
-
-class W_ListObject(W_SeqObject):
+class W_ListObject(W_Object):
from pypy.objspace.std.listtype import list_typedef as typedef
def __init__(w_self, wrappeditems):
@@ -26,13 +24,6 @@
def append(w_list, w_item):
w_list.wrappeditems.append(w_item)
- def getlength(self):
- return len(self.wrappeditems)
-
- def getitemfast(self, i):
- return self.wrappeditems[i]
-
-
registerimplementation(W_ListObject)
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/marshal_impl.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/marshal_impl.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/marshal_impl.py Sat Sep 20 17:52:36 2008
@@ -343,7 +343,7 @@
def marshal_w__DictMulti(space, w_dict, m):
m.start(TYPE_DICT)
for w_tuple in w_dict.implementation.items():
- w_key, w_value = space.unpacktuple(w_tuple, 2)
+ w_key, w_value = space.viewiterable(w_tuple, 2)
m.put_w_obj(w_key)
m.put_w_obj(w_value)
m.atom(TYPE_NULL)
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/objspace.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/objspace.py Sat Sep 20 17:52:36 2008
@@ -379,7 +379,7 @@
space = self
# too early for unpackiterable as well :-(
name = space.unwrap(space.getitem(w_args, space.wrap(0)))
- bases = space.unpacktuple(space.getitem(w_args, space.wrap(1)))
+ bases = space.viewiterable(space.getitem(w_args, space.wrap(1)))
dic = space.unwrap(space.getitem(w_args, space.wrap(2)))
dic = dict([(key,space.wrap(value)) for (key, value) in dic.items()])
bases = list(bases)
@@ -629,12 +629,32 @@
return instance
allocate_instance._annspecialcase_ = "specialize:arg(1)"
- def unpacktuple(self, w_tuple, expected_length=-1):
- assert isinstance(w_tuple, self.TupleObjectCls)
- t = w_tuple.getitems()
- if expected_length != -1 and expected_length != len(t):
- raise ValueError, "got a tuple of length %d instead of %d" % (
- len(t), expected_length)
+ # two following functions are almost identical, but in fact they
+ # have different return type. First one is a resizable list, second
+ # one is not
+
+ def unpackiterable(self, w_obj, expected_length=-1):
+ if isinstance(w_obj, W_TupleObject):
+ t = w_obj.wrappeditems[:]
+ elif isinstance(w_obj, W_ListObject):
+ t = w_obj.wrappeditems[:]
+ else:
+ return ObjSpace.unpackiterable(self, w_obj, expected_length)
+ if expected_length != -1 and len(t) != expected_length:
+ raise ValueError("Expected length %d, got %d" % (expected_length, len(t)))
+ return t
+
+ def viewiterable(self, w_obj, expected_length=-1):
+ """ Fast paths
+ """
+ if isinstance(w_obj, W_TupleObject):
+ t = w_obj.wrappeditems
+ elif isinstance(w_obj, W_ListObject):
+ t = w_obj.wrappeditems[:]
+ else:
+ return ObjSpace.viewiterable(self, w_obj, expected_length)
+ if expected_length != -1 and len(t) != expected_length:
+ raise ValueError("Expected length %d, got %d" % (expected_length, len(t)))
return t
def sliceindices(self, w_slice, w_length):
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeobject.py Sat Sep 20 17:52:36 2008
@@ -533,7 +533,7 @@
def str_endswith__Rope_Tuple_ANY_ANY(space, w_self, w_suffixes, w_start, w_end):
(self, _, start, end) = _convert_idx_params(space, w_self,
W_RopeObject.EMPTY, w_start, w_end)
- for w_suffix in space.unpacktuple(w_suffixes):
+ for w_suffix in space.viewiterable(w_suffixes):
if space.is_true(space.isinstance(w_suffix, space.w_unicode)):
w_u = space.call_function(space.w_unicode, w_self)
return space.call_method(w_u, "endswith", w_suffixes, w_start,
@@ -552,7 +552,7 @@
def str_startswith__Rope_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end):
(self, _, start, end) = _convert_idx_params(space, w_self, W_RopeObject.EMPTY,
w_start, w_end)
- for w_prefix in space.unpacktuple(w_prefixes):
+ for w_prefix in space.viewiterable(w_prefixes):
if space.is_true(space.isinstance(w_prefix, space.w_unicode)):
w_u = space.call_function(space.w_unicode, w_self)
return space.call_method(w_u, "startswith", w_prefixes, w_start,
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeunicodeobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeunicodeobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/ropeunicodeobject.py Sat Sep 20 17:52:36 2008
@@ -485,7 +485,7 @@
def unicode_startswith__RopeUnicode_Tuple_ANY_ANY(space, w_unistr, w_prefixes,
w_start, w_end):
unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end)
- for w_prefix in space.unpacktuple(w_prefixes):
+ for w_prefix in space.viewiterable(w_prefixes):
prefix = ropeunicode_w(space, w_prefix)
if rope.startswith(unistr, prefix, start, end):
return space.w_True
@@ -494,7 +494,7 @@
def unicode_endswith__RopeUnicode_Tuple_ANY_ANY(space, w_unistr, w_suffixes,
w_start, w_end):
unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end)
- for w_suffix in space.unpacktuple(w_suffixes):
+ for w_suffix in space.viewiterable(w_suffixes):
suffix = ropeunicode_w(space, w_suffix)
if rope.endswith(unistr, suffix, start, end):
return space.w_True
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/stringobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/stringobject.py Sat Sep 20 17:52:36 2008
@@ -593,7 +593,7 @@
def str_endswith__String_Tuple_ANY_ANY(space, w_self, w_suffixes, w_start, w_end):
(u_self, _, start, end) = _convert_idx_params(space, w_self,
space.wrap(''), w_start, w_end)
- for w_suffix in space.unpacktuple(w_suffixes):
+ for w_suffix in space.viewiterable(w_suffixes):
if space.is_true(space.isinstance(w_suffix, space.w_unicode)):
w_u = space.call_function(space.w_unicode, w_self)
return space.call_method(w_u, "endswith", w_suffixes, w_start,
@@ -611,7 +611,7 @@
def str_startswith__String_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end):
(u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(''),
w_start, w_end)
- for w_prefix in space.unpacktuple(w_prefixes):
+ for w_prefix in space.viewiterable(w_prefixes):
if space.is_true(space.isinstance(w_prefix, space.w_unicode)):
w_u = space.call_function(space.w_unicode, w_self)
return space.call_method(w_u, "startswith", w_prefixes, w_start,
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/strsliceobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/strsliceobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/strsliceobject.py Sat Sep 20 17:52:36 2008
@@ -141,7 +141,7 @@
def str_endswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_suffixes, w_start, w_end):
(u_self, _, start, end) = _convert_idx_params(space, w_self,
space.wrap(''), w_start, w_end)
- for w_suffix in space.unpacktuple(w_suffixes):
+ for w_suffix in space.viewiterable(w_suffixes):
suffix = space.str_w(w_suffix)
if stringendswith(u_self, suffix, start, end):
return space.w_True
@@ -155,7 +155,7 @@
def str_startswith__StringSlice_Tuple_ANY_ANY(space, w_self, w_prefixes, w_start, w_end):
(u_self, _, start, end) = _convert_idx_params(space, w_self, space.wrap(''),
w_start, w_end)
- for w_prefix in space.unpacktuple(w_prefixes):
+ for w_prefix in space.viewiterable(w_prefixes):
prefix = space.str_w(w_prefix)
if stringstartswith(u_self, prefix, start, end):
return space.w_True
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/tupleobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/tupleobject.py Sat Sep 20 17:52:36 2008
@@ -1,12 +1,11 @@
from pypy.objspace.std.objspace import *
-from pypy.objspace.std.seqinterface import W_SeqObject
from pypy.objspace.std.inttype import wrapint
from pypy.rlib.rarithmetic import intmask
from pypy.objspace.std.sliceobject import W_SliceObject
from pypy.interpreter import gateway
from pypy.rlib.debug import make_sure_not_resized
-class W_TupleObject(W_SeqObject):
+class W_TupleObject(W_Object):
from pypy.objspace.std.tupletype import tuple_typedef as typedef
def __init__(w_self, wrappeditems):
@@ -22,15 +21,6 @@
items = [space.unwrap(w_item) for w_item in w_tuple.wrappeditems] # XXX generic mixed types unwrap
return tuple(items)
- def getitems(self):
- return self.wrappeditems
-
- def getlength(self):
- return len(self.wrappeditems)
-
- def getitemfast(self, i):
- return self.wrappeditems[i]
-
registerimplementation(W_TupleObject)
Modified: pypy/branch/tuple-nonresizable-395/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/objspace/std/unicodeobject.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/objspace/std/unicodeobject.py Sat Sep 20 17:52:36 2008
@@ -474,7 +474,7 @@
def unicode_startswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_prefixes,
w_start, w_end):
unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end)
- for w_prefix in space.unpacktuple(w_prefixes):
+ for w_prefix in space.viewiterable(w_prefixes):
prefix = space.unicode_w(w_prefix)
if _check_startswith_substring(unistr, prefix, start, end):
return space.w_True
@@ -483,7 +483,7 @@
def unicode_endswith__Unicode_Tuple_ANY_ANY(space, w_unistr, w_suffixes,
w_start, w_end):
unistr, start, end = _convert_idx_params(space, w_unistr, w_start, w_end)
- for w_suffix in space.unpacktuple(w_suffixes):
+ for w_suffix in space.viewiterable(w_suffixes):
suffix = space.unicode_w(w_suffix)
if _check_endswith_substring(unistr, suffix, start, end):
return space.w_True
More information about the Pypy-commit
mailing list