[pypy-svn] r58002 - in pypy/branch/tuple-nonresizable-395/pypy/annotation: . test
fijal at codespeak.net
fijal at codespeak.net
Tue Sep 9 14:07:46 CEST 2008
Author: fijal
Date: Tue Sep 9 14:07:44 2008
New Revision: 58002
Modified:
pypy/branch/tuple-nonresizable-395/pypy/annotation/binaryop.py
pypy/branch/tuple-nonresizable-395/pypy/annotation/model.py
pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py
pypy/branch/tuple-nonresizable-395/pypy/annotation/unaryop.py
Log:
Revert SomeListIterator. Based on discussion with armin we should instead
a) create different helpers if necessary
b) grow superclass of W_TupleObject and W_ListObject (W_SeqObject) and use
it's method calls instead for non-performance-critical operations.
Modified: pypy/branch/tuple-nonresizable-395/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/annotation/binaryop.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/annotation/binaryop.py Tue Sep 9 14:07:44 2008
@@ -20,7 +20,6 @@
from pypy.annotation.model import add_knowntypedata, merge_knowntypedata
from pypy.annotation.model import SomeGenericCallable
from pypy.annotation.model import SomeExternalInstance, SomeUnicodeString
-from pypy.annotation.model import SomeListIterator
from pypy.annotation.bookkeeper import getbookkeeper
from pypy.objspace.flow.model import Variable, Constant
from pypy.rlib import rarithmetic
@@ -779,17 +778,6 @@
raise UnionError("merging incompatible iterators variants")
return SomeIterator(s_cont, *iter1.variant)
-class __extend__(pairtype(SomeListIterator, SomeListIterator)):
- def union((iter1, iter2)):
- # merge here s_value of listdefs, but not listdefs themselves
- # (ie resizable and mergeable parameters)
- # XXX should we perform some better union???
- for listdef in iter1.listdefs:
- listdef.generalize(iter2.listdefs[0].listitem.s_value)
- for listdef in iter2.listdefs:
- listdef.generalize(iter1.listdefs[0].listitem.s_value)
- listdefs = dict.fromkeys(iter1.listdefs + iter2.listdefs).keys()
- return SomeListIterator(listdefs)
class __extend__(pairtype(SomeBuiltin, SomeBuiltin)):
Modified: pypy/branch/tuple-nonresizable-395/pypy/annotation/model.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/annotation/model.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/annotation/model.py Tue Sep 9 14:07:44 2008
@@ -323,15 +323,6 @@
def can_be_none(self):
return False
-class SomeListIterator(SomeObject):
- def __init__(self, listdefs):
- self.listdefs = listdefs
-
- def __eq__(self, other):
- if not isinstance(other, SomeListIterator):
- return False
- return dict.fromkeys(self.listdefs) == dict.fromkeys(other.listdefs)
-
class SomeInstance(SomeObject):
"Stands for an instance of a (user-defined) class."
Modified: pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/annotation/test/test_annrpython.py Tue Sep 9 14:07:44 2008
@@ -443,7 +443,7 @@
def test_simple_iter_list(self):
a = self.RPythonAnnotator()
s = a.build_types(snippet.simple_iter, [list])
- assert isinstance(s, annmodel.SomeListIterator)
+ assert isinstance(s, annmodel.SomeIterator)
def test_simple_iter_next(self):
def f(x):
@@ -3097,19 +3097,7 @@
a = self.RPythonAnnotator()
py.test.raises(TooLateForChange, a.build_types, f, [])
-
- def test_mixing_iterators(self):
- def f(i):
- if i:
- return iter([1,2,3])
- else:
- l = [1,2,3]
- l.append(4)
- return iter(l)
-
- a = self.RPythonAnnotator()
- s_res = a.build_types(f, [int])
- assert isinstance(s_res, annmodel.SomeListIterator)
+
def g(n):
return [0,1,2,n]
Modified: pypy/branch/tuple-nonresizable-395/pypy/annotation/unaryop.py
==============================================================================
--- pypy/branch/tuple-nonresizable-395/pypy/annotation/unaryop.py (original)
+++ pypy/branch/tuple-nonresizable-395/pypy/annotation/unaryop.py Tue Sep 9 14:07:44 2008
@@ -9,7 +9,7 @@
SomeExternalObject, SomeTypedAddressAccess, SomeAddress, \
s_ImpossibleValue, s_Bool, s_None, \
unionof, set, missing_operation, add_knowntypedata, HarmlesslyBlocked, \
- SomeGenericCallable, SomeWeakRef, SomeUnicodeString, SomeListIterator
+ SomeGenericCallable, SomeWeakRef, SomeUnicodeString
from pypy.annotation.bookkeeper import getbookkeeper
from pypy.annotation import builtin
from pypy.annotation.binaryop import _clone ## XXX where to put this?
@@ -315,7 +315,7 @@
return SomeObject.len(lst)
def iter(lst):
- return SomeListIterator([lst.listdef])
+ return SomeIterator(lst)
iter.can_only_throw = []
def getanyitem(lst):
@@ -529,15 +529,6 @@
next.can_only_throw = _can_only_throw
method_next = next
-class __extend__(SomeListIterator):
- def iter(itr):
- return itr
- iter.can_only_throw = []
-
- def next(itr):
- return itr.listdefs[0].read_item()
- next.can_only_throw = [StopIteration]
- method_next = next
class __extend__(SomeInstance):
More information about the Pypy-commit
mailing list