[pypy-commit] pypy typed-cells: move _write_cell to PlainAttribute
cfbolz
noreply at buildbot.pypy.org
Fri Jan 23 10:42:16 CET 2015
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: typed-cells
Changeset: r75495:77a1f797146f
Date: 2015-01-23 00:38 +0100
http://bitbucket.org/pypy/pypy/changeset/77a1f797146f/
Log: move _write_cell to PlainAttribute
diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -58,22 +58,11 @@
# introduce cells only on the second write, to make immutability for
# int fields still work
cell = obj._mapdict_read_storage(attr.storageindex)
- w_value = self._write_cell(attr.space, cell, w_value)
+ w_value = attr._write_cell(attr.space, cell, w_value)
if w_value is not None:
obj._mapdict_write_storage(attr.storageindex, w_value)
return True
- def _write_cell(self, space, w_cell, w_value):
- from pypy.objspace.std.intobject import W_IntObject
- assert not isinstance(w_cell, ObjectMutableCell)
- if isinstance(w_cell, IntMutableCell) and type(w_value) is W_IntObject:
- w_cell.intvalue = w_value.intval
- return None
- if type(w_value) is W_IntObject:
- return IntMutableCell(w_value.intval)
- return w_value
-
-
def delete(self, obj, selector):
pass
@@ -304,6 +293,16 @@
self._size_estimate = self.length() * NUM_DIGITS_POW2
self.ever_mutated = False
+ def _write_cell(self, w_cell, w_value):
+ from pypy.objspace.std.intobject import W_IntObject
+ assert not isinstance(w_cell, ObjectMutableCell)
+ if isinstance(w_cell, IntMutableCell) and type(w_value) is W_IntObject:
+ w_cell.intvalue = w_value.intval
+ return None
+ if type(w_value) is W_IntObject:
+ return IntMutableCell(w_value.intval)
+ return w_value
+
def _copy_attr(self, obj, new_obj):
w_value = self.read(obj, self.selector)
new_obj._get_mapdict_map().add_attr(new_obj, self.selector, w_value)
More information about the pypy-commit
mailing list