[pypy-svn] r73104 - pypy/branch/cleanup-objspace-init/pypy/objspace/std
benjamin at codespeak.net
benjamin at codespeak.net
Mon Mar 29 18:46:16 CEST 2010
Author: benjamin
Date: Mon Mar 29 18:46:05 2010
New Revision: 73104
Modified:
pypy/branch/cleanup-objspace-init/pypy/objspace/std/boolobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/complexobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictmultiobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxyobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/floatobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/intobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/iterobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/listobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/longobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/model.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/noneobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/objectobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/objspace.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/proxyobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/rangeobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeunicodeobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/setobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/sliceobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/smallintobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/strjoinobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/strsliceobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupleobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/typeobject.py
pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodeobject.py
Log:
move towards removing the dependence of objects on objspace.py
* move registerimplementation to model.py and use a set
* remove "from pypy.objspace.std.objspace import *"
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/boolobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/boolobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/boolobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.objspace import *
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.intobject import W_IntObject
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/complexobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/complexobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/complexobject.py Mon Mar 29 18:46:05 2010
@@ -1,6 +1,7 @@
from pypy.interpreter import gateway
-from pypy.objspace.std.objspace import W_Object, OperationError
-from pypy.objspace.std.objspace import registerimplementation, register_all
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.floatobject import W_FloatObject, _hash_float
import math
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictmultiobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictmultiobject.py Mon Mar 29 18:46:05 2010
@@ -1,6 +1,6 @@
import py, sys
-from pypy.objspace.std.objspace import register_all, W_Object
-from pypy.objspace.std.objspace import registerimplementation
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter.argument import Signature
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxyobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxyobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/dictproxyobject.py Mon Mar 29 18:46:05 2010
@@ -1,11 +1,12 @@
-from pypy.objspace.std.objspace import *
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
def descr_get_dictproxy(space, w_obj):
return W_DictProxyObject(w_obj.getdict())
class W_DictProxyObject(W_Object):
from pypy.objspace.std.dictproxytype import dictproxy_typedef as typedef
-
+
def __init__(w_self, w_dict):
w_self.w_dict = w_dict
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/floatobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/floatobject.py Mon Mar 29 18:46:05 2010
@@ -1,11 +1,15 @@
import operator, new
-from pypy.objspace.std.objspace import *
from pypy.interpreter import gateway
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.objspace import StdObjSpace
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.longobject import W_LongObject
from pypy.rlib.rarithmetic import ovfcheck_float_to_int, intmask, isinf, isnan
from pypy.rlib.rarithmetic import formatd, LONG_BIT
from pypy.rlib.rbigint import rbigint
+from pypy.tool.sourcetools import func_with_new_name
import math
from pypy.objspace.std.intobject import W_IntObject
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/intobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/intobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/intobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,7 @@
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.multimethod import FailedToImplementArgs
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT, r_uint
from pypy.rlib.rbigint import rbigint
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/iterobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/iterobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/iterobject.py Mon Mar 29 18:46:05 2010
@@ -4,7 +4,9 @@
tested, and complete. The only missing feature is support
for function-iteration.
"""
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
class W_AbstractSeqIterObject(W_Object):
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/listobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/listobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/listobject.py Mon Mar 29 18:46:05 2010
@@ -1,5 +1,5 @@
-from pypy.objspace.std.objspace import register_all, W_Object
-from pypy.objspace.std.objspace import registerimplementation
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.objspace.std.inttype import wrapint
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/longobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/longobject.py Mon Mar 29 18:46:05 2010
@@ -1,5 +1,9 @@
import sys
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.objspace import StdObjSpace
+from pypy.objspace.std.multimethod import FailedToImplementArgs
from pypy.objspace.std.intobject import W_IntObject
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.rlib.rbigint import rbigint, SHIFT
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/model.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/model.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/model.py Mon Mar 29 18:46:05 2010
@@ -8,6 +8,12 @@
import pypy.interpreter.pycode
import pypy.interpreter.special
+_registered_implementations = set()
+def registerimplementation(implcls):
+ """Hint to objspace.std.model to register the implementation class."""
+ assert issubclass(implcls, W_Object)
+ _registered_implementations.add(implcls)
+
option_to_typename = {
"withsmallint" : ["smallintobject.W_SmallIntObject"],
"withstrslice" : ["strsliceobject.W_StringSliceObject"],
@@ -132,8 +138,7 @@
if config.objspace.std.withrope:
del self.typeorder[stringobject.W_StringObject]
- #check if we missed implementations
- from pypy.objspace.std.objspace import _registered_implementations
+ # check if we missed implementations
for implcls in _registered_implementations:
assert (implcls in self.typeorder or
implcls in self.imported_but_not_registered), (
@@ -146,7 +151,7 @@
# register the order in which types are converted into each others
# when trying to dispatch multimethods.
# XXX build these lists a bit more automatically later
-
+
if config.objspace.std.withsmallint:
self.typeorder[boolobject.W_BoolObject] += [
(smallintobject.W_SmallIntObject, boolobject.delegate_Bool2SmallInt),
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/noneobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/noneobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/noneobject.py Mon Mar 29 18:46:05 2010
@@ -2,9 +2,10 @@
None Object implementation
ok and tested
-"""
+"""
-from pypy.objspace.std.objspace import *
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
class W_NoneObject(W_Object):
from pypy.objspace.std.nonetype import none_typedef as typedef
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/objectobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/objectobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/objectobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.objspace import W_Object, register_all
+from pypy.objspace.std.model import W_Object
+from pypy.objspace.std.register_all import register_all
class W_ObjectObject(W_Object):
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/objspace.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/objspace.py Mon Mar 29 18:46:05 2010
@@ -20,13 +20,6 @@
import os
import __builtin__
-_registered_implementations = {}
-def registerimplementation(implcls):
- # hint to objspace.std.model to register the implementation class
- assert issubclass(implcls, W_Object)
- _registered_implementations[implcls] = True
-
-
##################################################################
class StdObjSpace(ObjSpace, DescrOperation):
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/proxyobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/proxyobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/proxyobject.py Mon Mar 29 18:46:05 2010
@@ -2,7 +2,7 @@
""" transparent list implementation
"""
-from pypy.objspace.std.objspace import *
+from pypy.objspace.std.model import registerimplementation, W_Object
from pypy.objspace.std.proxy_helpers import register_type
from pypy.interpreter.error import OperationError
from pypy.interpreter import baseobjspace, argument
@@ -73,7 +73,7 @@
W_Transparent.__name__ = name
return W_Transparent
-W_Transparent = transparent_class('W_Transparent', Wrappable)
+W_Transparent = transparent_class('W_Transparent', baseobjspace.Wrappable)
W_TransparentObject = transparent_class('W_TransparentObject', W_Object)
from pypy.objspace.std.objecttype import object_typedef
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/rangeobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/rangeobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/rangeobject.py Mon Mar 29 18:46:05 2010
@@ -1,12 +1,12 @@
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.multimethod import FailedToImplement
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.inttype import wrapint
from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
from pypy.objspace.std.listobject import W_ListObject
-from pypy.objspace.std import listtype
-from pypy.objspace.std import iterobject
-
-from pypy.objspace.std import slicetype
+from pypy.objspace.std import listtype, iterobject, slicetype
from pypy.interpreter import gateway, baseobjspace
def length(start, stop, step):
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeobject.py Mon Mar 29 18:46:05 2010
@@ -1,5 +1,5 @@
-from pypy.objspace.std.objspace import register_all, W_Object
-from pypy.objspace.std.objspace import registerimplementation
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter import gateway
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeunicodeobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeunicodeobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/ropeunicodeobject.py Mon Mar 29 18:46:05 2010
@@ -1,5 +1,5 @@
-from pypy.objspace.std.objspace import register_all, W_Object
-from pypy.objspace.std.objspace import registerimplementation
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter import gateway
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/setobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/setobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/setobject.py Mon Mar 29 18:46:05 2010
@@ -1,7 +1,8 @@
-from pypy.objspace.std.objspace import W_Object, OperationError
-from pypy.objspace.std.objspace import registerimplementation, register_all
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.rlib.objectmodel import r_dict
from pypy.rlib.rarithmetic import intmask, r_uint
+from pypy.interpreter.error import OperationError
from pypy.interpreter import gateway
from pypy.interpreter.argument import Signature
from pypy.objspace.std.settype import set_typedef as settypedef
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/sliceobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/sliceobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/sliceobject.py Mon Mar 29 18:46:05 2010
@@ -5,8 +5,10 @@
indices method tested, OK
"""
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
from pypy.interpreter import gateway
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.slicetype import _Eval_SliceIndex
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/smallintobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/smallintobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/smallintobject.py Mon Mar 29 18:46:05 2010
@@ -2,7 +2,9 @@
Implementation of small ints, stored as odd-valued pointers in the
translated PyPy. To enable them, see inttype.py.
"""
-from pypy.objspace.std.objspace import *
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
+from pypy.objspace.std.multimethod import FailedToImplementArgs
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT, r_uint
from pypy.objspace.std.inttype import wrapint
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/stringobject.py Mon Mar 29 18:46:05 2010
@@ -1,5 +1,5 @@
-from pypy.objspace.std.objspace import register_all, W_Object
-from pypy.objspace.std.objspace import registerimplementation
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.interpreter.error import OperationError, operationerrfmt
from pypy.interpreter import gateway
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/strjoinobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/strjoinobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/strjoinobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.objspace import *
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.stringobject import W_StringObject
from pypy.objspace.std.unicodeobject import delegate_String2Unicode
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/strsliceobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/strsliceobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/strsliceobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,6 @@
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.stringobject import W_StringObject
from pypy.objspace.std.unicodeobject import delegate_String2Unicode
from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupleobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupleobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/tupleobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,6 @@
-from pypy.objspace.std.objspace import *
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.inttype import wrapint
from pypy.rlib.rarithmetic import intmask
from pypy.objspace.std.sliceobject import W_SliceObject, normalize_simple_slice
@@ -8,7 +10,7 @@
class W_TupleObject(W_Object):
from pypy.objspace.std.tupletype import tuple_typedef as typedef
_immutable_ = True
-
+
def __init__(w_self, wrappeditems):
make_sure_not_resized(wrappeditems)
w_self.wrappeditems = wrappeditems # a list of wrapped values
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/typeobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/typeobject.py Mon Mar 29 18:46:05 2010
@@ -1,4 +1,5 @@
-from pypy.objspace.std.objspace import register_all, W_Object
+from pypy.objspace.std.model import W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.interpreter.function import Function, StaticMethod
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError, operationerrfmt
Modified: pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodeobject.py (original)
+++ pypy/branch/cleanup-objspace-init/pypy/objspace/std/unicodeobject.py Mon Mar 29 18:46:05 2010
@@ -1,5 +1,5 @@
-from pypy.objspace.std.objspace import register_all, W_Object
-from pypy.objspace.std.objspace import registerimplementation
+from pypy.objspace.std.model import registerimplementation, W_Object
+from pypy.objspace.std.register_all import register_all
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError, operationerrfmt
More information about the Pypy-commit
mailing list