[pypy-commit] pypy default: Change the _mixin_ class DescrOperation into an import_from_mixin() class.
arigo
noreply at buildbot.pypy.org
Tue Aug 20 14:41:44 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r66259:ae87826527de
Date: 2013-08-20 14:41 +0200
http://bitbucket.org/pypy/pypy/changeset/ae87826527de/
Log: Change the _mixin_ class DescrOperation into an import_from_mixin()
class. There are a couple of subtle possible differences (so I'll
run all tests now)
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -121,7 +121,7 @@
greens=['w_type'], reds='auto')
class DescrOperation(object):
- _mixin_ = True
+ # This is meant to be a *mixin*.
def is_data_descr(space, w_obj):
return space.lookup(w_obj, '__set__') is not None
@@ -867,12 +867,12 @@
elif _arity == 2 and len(_specialnames) == 2:
#print "binop", _specialnames
_impl_maker = _make_binop_impl
- elif _arity == 1 and len(_specialnames) == 1:
+ elif _arity == 1 and len(_specialnames) == 1 and _name != 'int':
#print "unaryop", _specialnames
_impl_maker = _make_unaryop_impl
if _impl_maker:
setattr(DescrOperation,_name,_impl_maker(_symbol,_specialnames))
- elif _name not in ['is_', 'id','type','issubtype',
+ elif _name not in ['is_', 'id','type','issubtype', 'int',
# not really to be defined in DescrOperation
'ord', 'unichr', 'unicode']:
raise Exception, "missing def for operation %s" % _name
diff --git a/pypy/objspace/std/builtinshortcut.py b/pypy/objspace/std/builtinshortcut.py
--- a/pypy/objspace/std/builtinshortcut.py
+++ b/pypy/objspace/std/builtinshortcut.py
@@ -131,6 +131,7 @@
w_obj = w_res
# general case fallback
- return DescrOperation.is_true(space, w_obj)
+ return _DescrOperation_is_true(space, w_obj)
+ _DescrOperation_is_true = DescrOperation.is_true.im_func
space.is_true = is_true
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
@@ -10,7 +10,7 @@
from rpython.rlib.objectmodel import instantiate, specialize, is_annotation_constant
from rpython.rlib.debug import make_sure_not_resized
from rpython.rlib.rarithmetic import base_int, widen, is_valid_int
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, import_from_mixin
from rpython.rlib import jit
# Object imports
@@ -37,9 +37,10 @@
from pypy.objspace.std.stringtype import wrapstr
from pypy.objspace.std.unicodetype import wrapunicode
-class StdObjSpace(ObjSpace, DescrOperation):
+class StdObjSpace(ObjSpace):
"""The standard object space, implementing a general-purpose object
library in Restricted Python."""
+ import_from_mixin(DescrOperation)
def initialize(self):
"NOT_RPYTHON: only for initializing the space."
@@ -492,16 +493,19 @@
self.wrap("Expected tuple of length 3"))
return self.int_w(l_w[0]), self.int_w(l_w[1]), self.int_w(l_w[2])
+ _DescrOperation_is_true = is_true
+ _DescrOperation_getattr = getattr
+
def is_true(self, w_obj):
# a shortcut for performance
# NOTE! this method is typically overridden by builtinshortcut.py.
if type(w_obj) is W_BoolObject:
return w_obj.boolval
- return DescrOperation.is_true(self, w_obj)
+ return self._DescrOperation_is_true(w_obj)
def getattr(self, w_obj, w_name):
if not self.config.objspace.std.getattributeshortcut:
- return DescrOperation.getattr(self, w_obj, w_name)
+ return self._DescrOperation_getattr(w_obj, w_name)
# an optional shortcut for performance
w_type = self.type(w_obj)
More information about the pypy-commit
mailing list