Author: Manuel Jacob Branch: kill-multimethod Changeset: r69451:750998b0ec09 Date: 2014-02-26 04:52 +0100 http://bitbucket.org/pypy/pypy/changeset/750998b0ec09/
Log: Kill pypy.objspace.std.stdtypedef and move TypeCache to pypy.objspace.std.typeobject. diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py --- a/pypy/objspace/std/objspace.py +++ b/pypy/objspace/std/objspace.py @@ -3,7 +3,7 @@ from pypy.interpreter.baseobjspace import ObjSpace, W_Root from pypy.interpreter.error import OperationError, oefmt from pypy.interpreter.typedef import get_unique_interplevel_subclass -from pypy.objspace.std import stdtypedef, frame, transparent, callmethod +from pypy.objspace.std import frame, transparent, callmethod from pypy.objspace.descroperation import DescrOperation, raiseattrerror from rpython.rlib.objectmodel import instantiate, specialize, is_annotation_constant from rpython.rlib.debug import make_sure_not_resized @@ -28,7 +28,7 @@ from pypy.objspace.std.setobject import W_SetObject, W_FrozensetObject from pypy.objspace.std.sliceobject import W_SliceObject from pypy.objspace.std.tupleobject import W_AbstractTupleObject, W_TupleObject -from pypy.objspace.std.typeobject import W_TypeObject +from pypy.objspace.std.typeobject import W_TypeObject, TypeCache from pypy.objspace.std.unicodeobject import W_UnicodeObject, wrapunicode @@ -118,10 +118,10 @@ return self.gettypeobject(cls.typedef) def gettypeobject(self, typedef): - # stdtypedef.TypeCache maps each StdTypeDef instance to its + # typeobject.TypeCache maps a TypeDef instance to its # unique-for-this-space W_TypeObject instance assert typedef is not None - return self.fromcache(stdtypedef.TypeCache).getorbuild(typedef) + return self.fromcache(TypeCache).getorbuild(typedef) def wrap(self, x): "Wraps the Python value 'x' into one of the wrapper classes." diff --git a/pypy/objspace/std/stdtypedef.py b/pypy/objspace/std/stdtypedef.py deleted file mode 100644 --- a/pypy/objspace/std/stdtypedef.py +++ /dev/null @@ -1,40 +0,0 @@ -from pypy.interpreter.baseobjspace import SpaceCache - - -class TypeCache(SpaceCache): - def build(cache, typedef): - "NOT_RPYTHON: initialization-time only." - # build a W_TypeObject from this StdTypeDef - from pypy.objspace.std.typeobject import W_TypeObject - from pypy.objspace.std.objectobject import W_ObjectObject - - space = cache.space - w = space.wrap - rawdict = typedef.rawdict - lazyloaders = {} - - # compute the bases - if typedef is W_ObjectObject.typedef: - bases_w = [] - else: - bases = typedef.bases or [W_ObjectObject.typedef] - bases_w = [space.gettypeobject(base) for base in bases] - - # wrap everything - dict_w = {} - for descrname, descrvalue in rawdict.items(): - dict_w[descrname] = w(descrvalue) - - if typedef.applevel_subclasses_base is not None: - overridetypedef = typedef.applevel_subclasses_base.typedef - else: - overridetypedef = typedef - w_type = W_TypeObject(space, typedef.name, bases_w, dict_w, - overridetypedef=overridetypedef) - if typedef is not overridetypedef: - w_type.w_doc = space.wrap(typedef.doc) - w_type.lazyloaders = lazyloaders - return w_type - - def ready(self, w_type): - w_type.ready() diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -1,5 +1,5 @@ from pypy.interpreter import gateway -from pypy.interpreter.baseobjspace import W_Root +from pypy.interpreter.baseobjspace import W_Root, SpaceCache from pypy.interpreter.error import oefmt, OperationError from pypy.interpreter.function import Function, StaticMethod from pypy.interpreter.typedef import weakref_descr, GetSetProperty,\ @@ -1203,3 +1203,39 @@ names = [cls.getname(space) for cls in cycle] raise OperationError(space.w_TypeError, space.wrap( "cycle among base classes: " + ' < '.join(names))) + + +class TypeCache(SpaceCache): + def build(self, typedef): + "NOT_RPYTHON: initialization-time only." + from pypy.objspace.std.objectobject import W_ObjectObject + + space = self.space + rawdict = typedef.rawdict + lazyloaders = {} + + # compute the bases + if typedef is W_ObjectObject.typedef: + bases_w = [] + else: + bases = typedef.bases or [W_ObjectObject.typedef] + bases_w = [space.gettypeobject(base) for base in bases] + + # wrap everything + dict_w = {} + for descrname, descrvalue in rawdict.items(): + dict_w[descrname] = space.wrap(descrvalue) + + if typedef.applevel_subclasses_base is not None: + overridetypedef = typedef.applevel_subclasses_base.typedef + else: + overridetypedef = typedef + w_type = W_TypeObject(space, typedef.name, bases_w, dict_w, + overridetypedef=overridetypedef) + if typedef is not overridetypedef: + w_type.w_doc = space.wrap(typedef.doc) + w_type.lazyloaders = lazyloaders + return w_type + + def ready(self, w_type): + w_type.ready() _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit