[pypy-commit] pypy default: more base methods
cfbolz
pypy.commits at gmail.com
Mon May 21 10:04:02 EDT 2018
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch:
Changeset: r94628:f0f9cfefd069
Date: 2018-05-18 10:42 +0200
http://bitbucket.org/pypy/pypy/changeset/f0f9cfefd069/
Log: more base methods
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -769,6 +769,9 @@
def __init__(self, space):
self.space = space
+ def get_empty_storage(self, sizehint):
+ raise NotImplementedError
+
def get_sizehint(self):
return -1
@@ -826,6 +829,9 @@
def getitems_float(self, w_list):
return None
+ def getitems_unroll(self, w_list):
+ raise NotImplementedError
+
def getstorage_copy(self, w_list):
raise NotImplementedError
@@ -1080,6 +1086,16 @@
strategy = w_list.strategy = self.space.fromcache(IntegerListStrategy)
w_list.lstorage = strategy.erase(items)
+ def step(self, w_list):
+ raise NotImplementedError
+
+ def _getitems_range(self, w_list, wrap_items):
+ raise NotImplementedError
+ _getitems_range_unroll = _getitems_range
+
+ def _getitem_range_unwrapped(self, w_list, i):
+ raise NotImplementedError
+
def wrap(self, intval):
return self.space.newint(intval)
@@ -1104,7 +1120,7 @@
w_other.lstorage = w_list.lstorage
def getitem(self, w_list, i):
- return self.wrap(self._getitem_unwrapped(w_list, i))
+ return self.wrap(self._getitem_range_unwrapped(w_list, i))
def getitems_int(self, w_list):
return self._getitems_range(w_list, False)
@@ -1194,7 +1210,7 @@
def step(self, w_list):
return 1
- def _getitem_unwrapped(self, w_list, i):
+ def _getitem_range_unwrapped(self, w_list, i):
length = self.unerase(w_list.lstorage)[0]
if i < 0:
i += length
@@ -1272,7 +1288,7 @@
def step(self, w_list):
return self.unerase(w_list.lstorage)[1]
- def _getitem_unwrapped(self, w_list, i):
+ def _getitem_range_unwrapped(self, w_list, i):
v = self.unerase(w_list.lstorage)
start = v[0]
step = v[1]
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -31,6 +31,9 @@
reprlist = [repr(w_item) for w_item in self.getkeys()]
return "<%s(%s)(%s)>" % (self.__class__.__name__, self.strategy, ', '.join(reprlist))
+ def _newobj(self, space, w_iterable):
+ raise NotImplementedError
+
def from_storage_and_strategy(self, storage, strategy):
obj = self._newobj(self.space, None)
assert isinstance(obj, W_BaseSetObject)
@@ -702,6 +705,12 @@
#def unerase(self, storage):
# raise NotImplementedError
+ def may_contain_equal_elements(self, strategy):
+ return True
+
+ def _intersect_wrapped(self, w_set, w_other):
+ raise NotImplementedError
+
# __________________ methods called on W_SetObject _________________
def clear(self, w_set):
@@ -1622,8 +1631,8 @@
if type(w_item) is not W_IntObject:
break
else:
- w_set.strategy = space.fromcache(IntegerSetStrategy)
- w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
+ strategy = w_set.strategy = space.fromcache(IntegerSetStrategy)
+ w_set.sstorage = strategy.get_storage_from_list(iterable_w)
return
# check for strings
@@ -1631,8 +1640,8 @@
if type(w_item) is not W_BytesObject:
break
else:
- w_set.strategy = space.fromcache(BytesSetStrategy)
- w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
+ strategy = w_set.strategy = space.fromcache(BytesSetStrategy)
+ w_set.sstorage = strategy.get_storage_from_list(iterable_w)
return
# check for unicode
@@ -1640,8 +1649,8 @@
if type(w_item) is not W_UnicodeObject:
break
else:
- w_set.strategy = space.fromcache(UnicodeSetStrategy)
- w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
+ strategy = w_set.strategy = space.fromcache(UnicodeSetStrategy)
+ w_set.sstorage = strategy.get_storage_from_list(iterable_w)
return
# check for compares by identity
@@ -1649,12 +1658,12 @@
if not space.type(w_item).compares_by_identity():
break
else:
- w_set.strategy = space.fromcache(IdentitySetStrategy)
- w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
+ strategy = w_set.strategy = space.fromcache(IdentitySetStrategy)
+ w_set.sstorage = strategy.get_storage_from_list(iterable_w)
return
- w_set.strategy = space.fromcache(ObjectSetStrategy)
- w_set.sstorage = w_set.strategy.get_storage_from_list(iterable_w)
+ strategy = w_set.strategy = space.fromcache(ObjectSetStrategy)
+ w_set.sstorage = strategy.get_storage_from_list(iterable_w)
create_set_driver = jit.JitDriver(name='create_set',
diff --git a/rpython/annotator/classdesc.py b/rpython/annotator/classdesc.py
--- a/rpython/annotator/classdesc.py
+++ b/rpython/annotator/classdesc.py
@@ -112,10 +112,14 @@
if not homedef.check_missing_attribute_update(attr):
for desc in s_newvalue.descriptions:
if desc.selfclassdef is None:
- raise AnnotatorError(
+ print AnnotatorError(
"demoting method %s from %s to class "
- "%s not allowed" % (self.name, desc.originclassdef, homedef)
+ "%s not allowed\n" % (self.name, desc.originclassdef, homedef) +
+ "either you need to add an abstract method to the base class\n" +
+ "or you need an assert isinstance(...) to ensure the annotator " +
+ "that the instance is of the right class"
)
+ break
# check for attributes forbidden by slots or _attrs_
if homedef.classdesc.all_enforced_attrs is not None:
diff --git a/rpython/memory/gc/inspector.py b/rpython/memory/gc/inspector.py
--- a/rpython/memory/gc/inspector.py
+++ b/rpython/memory/gc/inspector.py
@@ -103,6 +103,9 @@
self.seen = AddressDict()
self.pending = AddressStack()
+ def processobj(self, obj):
+ raise NotImplementedError("abstract base class")
+
def delete(self):
if self.gcflag == 0:
self.seen.delete()
diff --git a/rpython/rlib/buffer.py b/rpython/rlib/buffer.py
--- a/rpython/rlib/buffer.py
+++ b/rpython/rlib/buffer.py
@@ -57,6 +57,9 @@
"""Return the size in bytes."""
raise NotImplementedError
+ def get_raw_address(self):
+ raise NotImplementedError
+
def __len__(self):
res = self.getlength()
assert res >= 0
@@ -163,7 +166,7 @@
def decorate(targetcls):
"""
Create and attach specialized versions of typed_{read,write}. We need to
- do this becase the JIT codewriters mandates that base_ofs is an
+ do this because the JIT codewriters mandates that base_ofs is an
RPython constant.
"""
if targetcls.__bases__ != (GCBuffer,):
More information about the pypy-commit
mailing list