[pypy-dev] Re: Base Object library (was: stdobjspace status)

Stephan Diehl stephan.diehl at gmx.net
Wed Feb 26 17:42:35 CET 2003


On Wednesday 26 February 2003 16:34, you wrote:
> Stephan Diehl wrote:
> ...
>
> > This boils down to:
> > 1. define the most basic building blocks like bit fields + corresponding
> > memory management.
> > 2. define numbers, lists, strings, dicts, etc. on top of 1.
>
> This is actually my plan. It just takes more time.
>
> > Please note that these objects have nothing to do with the objspace we
> > are defining, but are used as the building blocks and are never exposed
> > outside the objspace.
> >
> > Does this make sense?
>
> Yes, makes sense.

Puh, so the week was not completely lost on me :-)

> For the time being, my r_int objects for instance
> are derived from true integers, but they are *meant*
> to denote simple, internal integers. Their
> behavior is modelled this way, and a compiler is
> supposed to recognize r_int and generate the primitive
> code instead of object calls. In that sense, I'm
> already using primitive types.

At the moment, the constructor of  W_IntObject looks like:

def __init__(w_self, intval):
        w_self.intval = r_int(intval)

At the end, this should look like:

def __init__(w_self, rintval):
        w_self.intval = rintval

where rintval is already the restricted intval.
Am I right here?

[...]

>
> So the meaning of the primitive types is always
> to provide a way down to the really implementable
> layers, regardless in which level of world you
> just happen to be. It even makes sense if you run
> PyPy on PyPy which is run on CPython, etc.

I take it then that in the end, we get something like the following:

########################
#       PyPy Interpreter            #
########################
#       StdObjSpace                   #
########################
#     basic/primitive Types     #
########################

These basic types have nothing to do at all with the StdObjSpace and are
implemented at first in Python (for convinience) and later probably in C or 
Assembler. 
The ObjSpace just has an interface to these basic types.
So, in the floatobject module for example, I'd rather define the
float_float_add function like this (I left out the errorchecking):

-------------------------------------------------------------------------
import basicfloat

def float_float_add(space, w_float1, w_float2):
    x = w_float1.floatval
    y = w_float2.floatval
    z = basicfloat.add(x,y)
    
    return W_FloatObject(z)
-------------------------------------------------------------------------

instead of
-------------------------------------------------------------------------
def float_float_add(space, w_float1, w_float2):
    x = w_float1.floatval
    y = w_float2.floatval
    z = x + y
    
    return W_FloatObject(z)
--------------------------------------------------------------------------

The most important thing seems to me to define content and interface of the 
basic types.
I'd suggest one module "basictypes" that defines the number and string 
definitions and operations. Apart from that (or together?) we'll need a 
general bitfield (bytefield?) and then, on top of that, the list and 
dictionary types.

Cheers

Stephan


>
> ciao - chris


More information about the Pypy-dev mailing list