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

Christian Tismer tismer at tismer.com
Wed Feb 26 18:33:39 CET 2003


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.

>>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.

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.

> 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.
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.

ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/



More information about the Pypy-dev mailing list