[pypy-commit] pypy SomeRange: Create SomeRange class
rlamy
pypy.commits at gmail.com
Sat Jan 30 13:42:39 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: SomeRange
Changeset: r82008:273c3ace813a
Date: 2016-01-30 17:40 +0000
http://bitbucket.org/pypy/pypy/changeset/273c3ace813a/
Log: Create SomeRange class
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -13,7 +13,8 @@
SomeOrderedDict, SomeString, SomeChar, SomeFloat, unionof, SomeInstance,
SomeDict, SomeBuiltin, SomePBC, SomeInteger, TLS, SomeUnicodeCodePoint,
s_None, s_ImpossibleValue, SomeBool, SomeTuple, SomeException,
- SomeImpossibleValue, SomeUnicodeString, SomeList, HarmlesslyBlocked,
+ SomeImpossibleValue, SomeUnicodeString, SomeList, SomeRange,
+ HarmlesslyBlocked,
SomeWeakRef, SomeByteArray, SomeConstantType, SomeProperty)
from rpython.annotator.classdesc import ClassDef, ClassDesc
from rpython.annotator.listdef import ListDef, ListItem
@@ -190,7 +191,7 @@
listdef.listitem.range_step = step
listdef.generalize(s_item)
listdef.generalize_range_step(step)
- return SomeList(listdef)
+ return SomeRange(listdef)
def getdictdef(self, is_r_dict=False, force_non_null=False):
"""Get the DictDef associated with the current position."""
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -359,6 +359,9 @@
def noneify(self):
return SomeList(self.listdef)
+class SomeRange(SomeList):
+ pass
+
class SomeTuple(SomeObject):
"Stands for a tuple of known length."
diff --git a/rpython/rtyper/rrange.py b/rpython/rtyper/rrange.py
--- a/rpython/rtyper/rrange.py
+++ b/rpython/rtyper/rrange.py
@@ -89,6 +89,9 @@
v_step = self._getstep(v_rng, hop)
return hop.gendirectcall(ll_rangelen, v_rng, v_step)
+ def __eq__(self, other):
+ return other.__class__ is self.__class__ and other.__dict__ == self.__dict__
+
class __extend__(pairtype(RangeRepr, IntegerRepr)):
More information about the pypy-commit
mailing list