[pypy-svn] r25701 - pypy/dist/pypy/objspace/std
stephan at codespeak.net
stephan at codespeak.net
Tue Apr 11 16:54:50 CEST 2006
Author: stephan
Date: Tue Apr 11 16:54:48 2006
New Revision: 25701
Modified:
pypy/dist/pypy/objspace/std/frozensettype.py
pypy/dist/pypy/objspace/std/setobject.py
pypy/dist/pypy/objspace/std/settype.py
Log:
all tests in lib-python/modified-2.4.1/test/test_set.py are now passing, but
the pickling for subtypes of set and frozenset (Actually, when running the commands in CLI, there is not problem). But, translation doesn't work yet. Still investigation (and fighting with the debugging process).
As always, pypy.objspace.std.model.WITHSET must be set to True to enable native set/frozenset implementation.
Modified: pypy/dist/pypy/objspace/std/frozensettype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/frozensettype.py (original)
+++ pypy/dist/pypy/objspace/std/frozensettype.py Tue Apr 11 16:54:48 2006
@@ -13,6 +13,7 @@
frozenset_issuperset = SMM('issuperset', 2)
frozenset_symmetric_difference = SMM('symmetric_difference', 2)
frozenset_union = SMM('union', 2)
+frozenset_reduce = SMM('__reduce__',1)
register_all(vars(), globals())
Modified: pypy/dist/pypy/objspace/std/setobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/setobject.py (original)
+++ pypy/dist/pypy/objspace/std/setobject.py Tue Apr 11 16:54:48 2006
@@ -12,6 +12,7 @@
W_Object.__init__(w_self, space)
w_self.setdata = setdata = r_dict(space.eq_w, space.hash_w)
_initialize_set(space, w_self, wrappeditems)
+ w_self.in_init = True
def __repr__(w_self):
"""representation for debugging purposes"""
@@ -346,7 +347,7 @@
hash *= (len(w_set.setdata) + 1)
for w_item in w_set.setdata.iterkeys():
h = space.int_w(space.hash(w_item))
- hash ^= (h ^ (h << 16) ^ 89869747) * 3644798167
+ hash ^= ((h ^ (h << 16) ^ 89869747) * 3644798167)
hash = hash * 69069 + 907133923
if hash == -1:
hash = 590923713
@@ -449,8 +450,11 @@
def init__Set(space, w_set, __args__):
w_iterable, = __args__.parse('set',
(['some_iterable'], None, None),
- [W_SetObject(space,None)])
- _initialize_set(space, w_set, w_iterable)
+ #[W_SetObject(space,None)])
+ [space.newtuple([])])
+ if not w_set.in_init:
+ _initialize_set(space, w_set, w_iterable)
+ w_set.in_init = False
app = gateway.applevel("""
def ne__Set_ANY(s, o):
@@ -465,6 +469,9 @@
def repr__Set(s):
return '%s(%s)' % (s.__class__.__name__, [x for x in s])
+ def reduce__Set(s):
+ return (s.__class__,(tuple(s),),None)
+
""", filename=__file__)
ne__Set_ANY = app.interphook("ne__Set_ANY")
@@ -483,6 +490,9 @@
repr__Set = app.interphook('repr__Set')
repr__Frozenset = app.interphook('repr__Set')
+set_reduce__Set = app.interphook('reduce__Set')
+frozenset_reduce__Frozenset = app.interphook('reduce__Set')
+
from pypy.objspace.std import frozensettype
from pypy.objspace.std import settype
Modified: pypy/dist/pypy/objspace/std/settype.py
==============================================================================
--- pypy/dist/pypy/objspace/std/settype.py (original)
+++ pypy/dist/pypy/objspace/std/settype.py Tue Apr 11 16:54:48 2006
@@ -22,6 +22,7 @@
set_symmetric_difference_update = SMM('symmetric_difference_update', 2)
set_union = SMM('union', 2)
set_update = SMM('update', 2)
+set_reduce = SMM('__reduce__',1)
register_all(vars(), globals())
More information about the Pypy-commit
mailing list