On Monday 05 July 2004 09:16, holger krekel wrote: > [Ben Young Mon, Jul 05, 2004 at 08:54:49AM +0100] > > > Ah, I think I have found the problem! pow(complex(0, 2), 2) does return > > the correct result, however stdobjspace.wrap(2j) does not return a > > complex object, it returns a cpython object. Is there a way to plug > > factory functions into the object space from the module directory or > > should the complex object be lifted to the level of int and long, and be > > put in the object space? > > Right, the underlying problem is that we reuse the co.co_consts objects > as compiled by the python compiler. The literal "2j" is represented as a > cpython-object in co_consts and the implementation of LOAD_CONST invokes > stdobjspace.wrap(cpython_complexobject) which does a > cpythonobject-wrapping instead of creating a proper builtin-level > complex instance. > > I think it's ok to add yet another special case to stdobjspace.wrap() > to create a proper complex object for compiled literals. The other > solution of having a proper complex object in co_consts from the start > is problematic because code objects in PyPy are considered an > objectspace-independent "dead" representation of the source code. > When we finally do parser/compiler integration we probably should > revisit this literal/wrapping issue. >
But is is possible to access module/__builtin__module from objspace/std or should complex be moved into the object spaces? Ben --- _______________________________________________ [EMAIL PROTECTED] http://codespeak.net/mailman/listinfo/pypy-dev
