[pypy-svn] r77193 - pypy/trunk/pypy/rpython/lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Mon Sep 20 11:14:33 CEST 2010
Author: arigo
Date: Mon Sep 20 11:14:32 2010
New Revision: 77193
Modified:
pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
Revert my changes to ll2ctypes: we decided that the hash of an ll2ctypes
object can change when the object is converted from lltype.
Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py Mon Sep 20 11:14:32 2010
@@ -349,23 +349,13 @@
cache[cls1, cls2] = subcls
return subcls
-_hack_stay_alive = [None] * 64
-_hack_stay_alive_index = 0
-
def add_storage(instance, mixin_cls, ctypes_storage):
"""Put ctypes_storage on the instance, changing its __class__ so that it
sees the methods of the given mixin class."""
assert not isinstance(instance, _parentable_mixin) # not yet
- ctypes_storage._preserved_hash = hash(instance)
subcls = get_common_subclass(mixin_cls, instance.__class__)
instance.__class__ = subcls
instance._storage = ctypes_storage
- #
- # hack hack hack. Avoids reusing too fast the same hashes :-/
- global _hack_stay_alive_index
- _hack_stay_alive_index = (_hack_stay_alive_index + 1) & 63
- _hack_stay_alive[_hack_stay_alive_index] = instance
-
class _parentable_mixin(object):
"""Mixin added to _parentable containers when they become ctypes-based.
@@ -412,8 +402,6 @@
def __hash__(self):
if self._storage is not None:
- if hasattr(self._storage, '_preserved_hash'):
- return self._storage._preserved_hash
return ctypes.addressof(self._storage)
else:
return object.__hash__(self)
More information about the Pypy-commit
mailing list