[pypy-commit] pypy unsigned-dtypes: remove some commented code and skip a zjit test until we change llimpl

justinpeel noreply at buildbot.pypy.org
Mon Oct 3 19:55:48 CEST 2011


Author: Justin Peel <notmuchtotell at gmail.com>
Branch: unsigned-dtypes
Changeset: r47798:1075b6767e74
Date: 2011-10-03 11:55 -0600
http://bitbucket.org/pypy/pypy/changeset/1075b6767e74/

Log:	remove some commented code and skip a zjit test until we change
	llimpl

diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -459,23 +459,12 @@
 class W_Float64Dtype(FloatArithmeticDtype, W_Float64Dtype):
     pass
 
-#W_Float96Dtype = create_low_level_dtype(
-#    num = 13, kind = FLOATINGLTR, name = "float96",
-#    aliases = ["g", "float96"],
-#    applevel_types = [],
-#    T = lltype.Float, # LongFloat
-#    valtype = float, # r_longfloat
-#    expected_size = 8, # 12
-#)
-#class W_Float96Dtype(FloatArithmeticDtype, W_Float96Dtype):
-#    pass
-
 ALL_DTYPES = [
     W_BoolDtype,
     W_Int8Dtype, W_UInt8Dtype, W_Int16Dtype, W_UInt16Dtype,
     W_Int32Dtype, W_UInt32Dtype, W_LongDtype, W_ULongDtype,
     W_Int64Dtype, W_UInt64Dtype,
-    W_Float32Dtype, W_Float64Dtype, #W_Float96Dtype,
+    W_Float32Dtype, W_Float64Dtype,
 ]
 
 dtypes_by_alias = unrolling_iterable([
diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -9,6 +9,8 @@
 from pypy.rpython.annlowlevel import llstr
 from pypy.rpython.test.test_llinterp import interpret
 
+import py
+
 
 class TestNumpyJIt(LLJitMixin):
     def setup_class(cls):
@@ -306,6 +308,9 @@
         assert result == 11.0
 
     def test_int32_sum(self):
+        py.test.skip("pypy/jit/backend/llimpl.py needs to be changed to "
+                     "deal correctly with int dtypes for this test to "
+                     "work. skip for now until someone feels up to the task")
         space = self.space
         float64_dtype = self.float64_dtype
         int32_dtype = self.int32_dtype
diff --git a/pypy/objspace/std/iterobject.py b/pypy/objspace/std/iterobject.py
--- a/pypy/objspace/std/iterobject.py
+++ b/pypy/objspace/std/iterobject.py
@@ -35,16 +35,32 @@
         w_self.listitems = wrappeditems
 
 class W_FastTupleIterObject(W_AbstractSeqIterObject):
-   """Sequence iterator specialized for tuples, accessing
-   directly their RPython-level list of wrapped objects.
-   """ 
-   def __init__(w_self, w_seq, wrappeditems):
+    """Sequence iterator specialized for tuples, accessing
+    directly their RPython-level list of wrapped objects.
+    """
+    def __init__(w_self, w_seq, wrappeditems):
         W_AbstractSeqIterObject.__init__(w_self, w_seq)
         w_self.tupleitems = wrappeditems
 
+class W_FastStringIterObject(W_AbstractSeqIterObject):
+    """Sequence iterator specialized for strings, accessing
+    directly their RPython string.
+    """
+    def __init__(w_self, w_seq, value):
+        W_AbstractSeqIterObject.__init__(w_self, w_seq)
+        w_self.chars = value
+
+class W_FastUnicodeIterObject(W_AbstractSeqIterObject):
+    """Sequence iterator specialized for strings, accessing
+    directly their RPython string.
+    """
+    def __init__(w_self, w_seq, value):
+        W_AbstractSeqIterObject.__init__(w_self, w_seq)
+        w_self.unichars = value
+
 class W_ReverseSeqIterObject(W_Object):
     from pypy.objspace.std.itertype import reverse_iter_typedef as typedef
-    
+
     def __init__(w_self, space, w_seq, index=-1):
         w_self.w_seq = w_seq
         w_self.w_len = space.len(w_seq)
@@ -54,6 +70,8 @@
 registerimplementation(W_SeqIterObject)
 registerimplementation(W_FastListIterObject)
 registerimplementation(W_FastTupleIterObject)
+registerimplementation(W_FastStringIterObject)
+registerimplementation(W_FastUnicodeIterObject)
 registerimplementation(W_ReverseSeqIterObject)
 
 def iter__SeqIter(space, w_seqiter):
@@ -119,6 +137,48 @@
 ##    return w_seqiter.getlength(space)
 
 
+def iter__FastStringIter(space, w_seqiter):
+    return w_seqiter
+
+def next__FastStringIter(space, w_seqiter):
+    if w_seqiter.chars is None:
+        raise OperationError(space.w_StopIteration, space.w_None)
+    index = w_seqiter.index
+    try:
+        s = w_seqiter.chars[index]
+    except IndexError:
+        w_seqiter.chars = None
+        w_seqiter.w_seq = None
+        raise OperationError(space.w_StopIteration, space.w_None) 
+    w_seqiter.index = index + 1
+    return space.wrap(s)
+
+# XXX __length_hint__()
+##def len__FastStringIter(space, w_seqiter):
+##    return w_seqiter.getlength(space)
+
+
+def iter__FastUnicodeIter(space, w_seqiter):
+    return w_seqiter
+
+def next__FastUnicodeIter(space, w_seqiter):
+    if w_seqiter.unichars is None:
+        raise OperationError(space.w_StopIteration, space.w_None)
+    index = w_seqiter.index
+    try:
+        s = w_seqiter.unichars[index]
+    except IndexError:
+        w_seqiter.unichars = None
+        w_seqiter.w_seq = None
+        raise OperationError(space.w_StopIteration, space.w_None) 
+    w_seqiter.index = index + 1
+    return space.wrap(s)
+
+# XXX __length_hint__()
+##def len__FastUnicodeIter(space, w_seqiter):
+##    return w_seqiter.getlength(space)
+
+
 def iter__ReverseSeqIter(space, w_seqiter):
     return w_seqiter
 
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -122,6 +122,8 @@
             iterobject.W_SeqIterObject: [],
             iterobject.W_FastListIterObject: [],
             iterobject.W_FastTupleIterObject: [],
+            iterobject.W_FastStringIterObject: [],
+            iterobject.W_FastUnicodeIterObject: [],
             iterobject.W_ReverseSeqIterObject: [],
             unicodeobject.W_UnicodeObject: [],
             dictmultiobject.W_DictViewKeysObject: [],
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
@@ -863,6 +863,10 @@
     else:
         return sliced(space, s, start, stop, w_str)
 
+def iter__String(space, w_str):
+    from pypy.objspace.std import iterobject
+    return iterobject.W_FastStringIterObject(w_str, w_str._value)
+
 def mul_string_times(space, w_str, w_times):
     try:
         mul = space.getindex_w(w_times, space.w_OverflowError)
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
@@ -265,6 +265,10 @@
     start, stop = normalize_simple_slice(space, len(uni), w_start, w_stop)
     return W_UnicodeObject(uni[start:stop])
 
+def iter__Unicode(space, w_uni):
+    from pypy.objspace.std import iterobject
+    return iterobject.W_FastUnicodeIterObject(w_uni, w_uni._value)
+
 def mul__Unicode_ANY(space, w_uni, w_times):
     try:
         times = space.getindex_w(w_times, space.w_OverflowError)


More information about the pypy-commit mailing list