[pypy-svn] r23150 - pypy/dist/pypy/objspace/std
stephan at codespeak.net
stephan at codespeak.net
Wed Feb 8 18:22:58 CET 2006
Author: stephan
Date: Wed Feb 8 18:22:54 2006
New Revision: 23150
Modified:
pypy/dist/pypy/objspace/std/model.py
pypy/dist/pypy/objspace/std/objspace.py
Log:
added a 'WITHCOMPLEX' switch to model.py. Set to 'True' for using native complex.
Modified: pypy/dist/pypy/objspace/std/model.py
==============================================================================
--- pypy/dist/pypy/objspace/std/model.py (original)
+++ pypy/dist/pypy/objspace/std/model.py Wed Feb 8 18:22:54 2006
@@ -8,6 +8,8 @@
import pypy.interpreter.pycode
import pypy.interpreter.special
+WITHCOMPLEX = False
+
class StdTypeModel:
def __init__(self):
@@ -18,7 +20,8 @@
from pypy.objspace.std.booltype import bool_typedef
from pypy.objspace.std.inttype import int_typedef
from pypy.objspace.std.floattype import float_typedef
- #from pypy.objspace.std.complextype import complex_typedef
+ if WITHCOMPLEX:
+ from pypy.objspace.std.complextype import complex_typedef
from pypy.objspace.std.tupletype import tuple_typedef
from pypy.objspace.std.listtype import list_typedef
from pypy.objspace.std.dicttype import dict_typedef
@@ -41,7 +44,8 @@
from pypy.objspace.std import boolobject
from pypy.objspace.std import intobject
from pypy.objspace.std import floatobject
- #from pypy.objspace.std import complexobject
+ if WITHCOMPLEX:
+ from pypy.objspace.std import complexobject
from pypy.objspace.std import tupleobject
from pypy.objspace.std import listobject
from pypy.objspace.std import dictobject
@@ -81,6 +85,8 @@
pypy.interpreter.pycode.PyCode: [],
pypy.interpreter.special.Ellipsis: [],
}
+ if WITHCOMPLEX:
+ self.typeorder[complexobject.W_ComplexObject] = []
for type in self.typeorder:
self.typeorder[type].append((type, None))
@@ -114,6 +120,19 @@
self.typeorder[stringobject.W_StringObject] += [
(unicodeobject.W_UnicodeObject, unicodeobject.delegate_String2Unicode),
]
+ if WITHCOMPLEX:
+ self.typeorder[boolobject.W_BoolObject] += [
+ (complexobject.W_ComplexObject, complexobject.delegate_Bool2Complex),
+ ]
+ self.typeorder[intobject.W_IntObject] += [
+ (complexobject.W_ComplexObject, complexobject.delegate_Int2Complex),
+ ]
+ self.typeorder[longobject.W_LongObject] += [
+ (complexobject.W_ComplexObject, complexobject.delegate_Long2Complex),
+ ]
+ self.typeorder[floatobject.W_FloatObject] += [
+ (complexobject.W_ComplexObject, complexobject.delegate_Float2Complex),
+ ]
# put W_Root everywhere
self.typeorder[W_Root] = []
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Wed Feb 8 18:22:54 2006
@@ -6,7 +6,7 @@
from pypy.interpreter.gateway import PyPyCacheDir
from pypy.tool.cache import Cache
from pypy.tool.sourcetools import func_with_new_name
-from pypy.objspace.std.model import W_Object, UnwrapError
+from pypy.objspace.std.model import W_Object, UnwrapError, WITHCOMPLEX
from pypy.objspace.std.model import W_ANY, StdObjSpaceMultiMethod, StdTypeModel
from pypy.objspace.std.multimethod import FailedToImplement
from pypy.objspace.descroperation import DescrOperation
@@ -276,18 +276,23 @@
return W_SliceObject(self, self.wrap(x.start),
self.wrap(x.stop),
self.wrap(x.step))
- # SD disable for native complex
if isinstance(x, complex):
+ if WITHCOMPLEX:
+ return W_ComplexObject(self, x.real, x.imag)
+ else:
+ c = self.builtin.get('complex')
+ return self.call_function(c,
+ self.wrap(x.real),
+ self.wrap(x.imag))
+
+ # SD disable for native complex
+ #if isinstance(x, complex):
# XXX is this right? YYY no, this is wrong right now (CT)
# ZZZ hum, seems necessary for complex literals in co_consts (AR)
c = self.builtin.get('complex')
- return self.call_function(c,
- self.wrap(x.real),
- self.wrap(x.imag))
-
- # SD activate for native complex
- #if isinstance(x, complex):
- # return W_ComplexObject(self, x.real, x.imag)
+ # return self.call_function(c,
+ # self.wrap(x.real),
+ # self.wrap(x.imag))
if self.options.nofaking:
# annotation should actually not get here
@@ -327,8 +332,9 @@
return W_FloatObject(self, floatval)
# SD needed for complex
- #def newcomplex(self, realval, imagval):
- # return W_ComplexObject(self, realval, imagval)
+ if WITHCOMPLEX:
+ def newcomplex(self, realval, imagval):
+ return W_ComplexObject(self, realval, imagval)
def newlong(self, val): # val is an int
return W_LongObject.fromint(self, val)
More information about the Pypy-commit
mailing list