[pypy-svn] r32584 - pypy/dist/pypy/rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Fri Sep 22 18:22:31 CEST 2006
Author: arigo
Date: Fri Sep 22 18:22:30 2006
New Revision: 32584
Modified:
pypy/dist/pypy/rpython/lltypesystem/lltype.py
Log:
(arre, arigo) Try to build a meaningful 'id' for _func objects.
Modified: pypy/dist/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/lltype.py Fri Sep 22 18:22:30 2006
@@ -1132,7 +1132,7 @@
if isinstance(obj, int):
return obj # special case for cast_int_to_ptr() results
obj = normalizeptr(self)._obj
- result = intmask(id(obj))
+ result = intmask(obj._getid())
# assume that id() returns an addressish value which is
# not zero and aligned to at least a multiple of 4
assert result != 0 and (result & 3) == 0
@@ -1170,6 +1170,8 @@
return self
def _normalizedcontainer(self):
return self
+ def _getid(self):
+ return id(self)
class _parentable(_container):
_kind = "?"
@@ -1467,6 +1469,9 @@
return _ptr(Ptr(subarray._TYPE), subarray, solid)
_makeptr = staticmethod(_makeptr)
+ def _getid(self):
+ raise NotImplementedError('_subarray._getid()')
+
class _func(_container):
def __init__(self, TYPE, **attrs):
@@ -1491,6 +1496,14 @@
def __hash__(self):
return hash(frozendict(self.__dict__))
+ def _getid(self):
+ if hasattr(self, 'graph'):
+ return id(self.graph)
+ elif self._callable:
+ return id(self._callable)
+ else:
+ return id(self)
+
def __getstate__(self):
import pickle, types
__dict__ = self.__dict__.copy()
@@ -1558,6 +1571,9 @@
def __str__(self):
return "pyobject %s" % (Hashable.__str__(self),)
+ def _getid(self):
+ return id(self.value)
+
class _pyobjheader(_parentable):
def __init__(self, parent=None, parentindex=None):
_parentable.__init__(self, PyObject)
More information about the Pypy-commit
mailing list