[pypy-svn] r25668 - pypy/dist/pypy/objspace/std
arigo at codespeak.net
arigo at codespeak.net
Mon Apr 10 17:40:47 CEST 2006
Author: arigo
Date: Mon Apr 10 17:40:45 2006
New Revision: 25668
Modified:
pypy/dist/pypy/objspace/std/register_all.py
pypy/dist/pypy/objspace/std/setobject.py
Log:
Allow several alternate namespaces in calls to register_all(). This
works in the case of setobject.py because in this case multimethods are
looked up by namespace key and not by multimethod name (so no conflict
between set_xxx and frozenset_xxx).
Modified: pypy/dist/pypy/objspace/std/register_all.py
==============================================================================
--- pypy/dist/pypy/objspace/std/register_all.py (original)
+++ pypy/dist/pypy/objspace/std/register_all.py Mon Apr 10 17:40:45 2006
@@ -4,7 +4,7 @@
'or': 'or_',
}
-def register_all(module_dict, alt_ns=None):
+def register_all(module_dict, *alt_ns):
"""register implementations for multimethods.
By default a (name, object) pair of the given module dictionary
@@ -14,9 +14,7 @@
"""
from pypy.objspace.std.objspace import StdObjSpace
from pypy.objspace.std.model import W_ANY, W_Object
- namespaces = [StdObjSpace.MM, StdObjSpace]
- if alt_ns:
- namespaces.insert(0, alt_ns)
+ namespaces = list(alt_ns) + [StdObjSpace.MM, StdObjSpace]
for name, obj in module_dict.items():
if name.startswith('app_'):
Modified: pypy/dist/pypy/objspace/std/setobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/setobject.py (original)
+++ pypy/dist/pypy/objspace/std/setobject.py Mon Apr 10 17:40:45 2006
@@ -467,15 +467,4 @@
from pypy.objspace.std import frozensettype
from pypy.objspace.std import settype
-# make sure that the 'register_all' function gets only the appropriate
-# methods
-
-sdg = [(n, m) for n, m in vars().items() if n.find('__Frozenset') == -1]
-fdg = [(n, m) for n, m in vars().items() if n.find('__Set') == -1]
-
-register_all(dict(sdg), settype)
-register_all(dict(fdg), frozensettype)
-
-# this doesn't work:
-#register_all(vars(), frozensettype)
-#register_all(vars(), settype)
+register_all(vars(), settype, frozensettype)
More information about the Pypy-commit
mailing list