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

Stephan Diehl stephan.diehl at gmx.net
Wed Feb 26 19:33:37 CET 2003


On Wednesday 26 February 2003 18:33, you wrote:
> Stephan Diehl wrote:
> ...
>
> > 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?
>
> May be, not sure, I only want to make sure
> that self.intval is an r_int.

I guess that depends a little on who'll create the W_ Objects.
(I have no idea yet)

>
[...]
> >
> > 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.
>
> Yes, but don't get me wrong:
> I will not rewrite them in C, but
> a code generator will do that.
> SO, actually, most of the work is done after
> writing it in Python.

No, my memory is not that bad :-)
I just wanted to emphasize, that the basic objects are in some way coming 
from somewhere else. It just doesn't matter if they were compiled from Python 
or implemented in some completely different language.

>
> > 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)
> > -------------------------------------------------------------------------
> >-
>
> Why that?
> You can do that, but I don't see the point.

The point (at least for me) is to distinguish the basic types from normal 
python in an optical way. I find it difficult enough not to get an headache 
over all these different levels of implementation and what kind of operation 
is allowed.
With the explicit library call I'd try to keep my confusion about this at bay.

> This is why I defined r_int as derived from
> true ints: I want to keep the simple notation
> of "+".
> Why should I use a special method?
> If there is a special method, then
> it can be found in the class definition
> of r_int.
>
> > 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.
>
> Yes. That is what I hope to do very soon.

I'll finish the floatobject module then and try to implement the number 
library I mentioned in my initial mail about that.

>
> ciao - chris

Have fun

Stephan


More information about the Pypy-dev mailing list