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

Stephan Diehl stephan.diehl at gmx.net
Wed Feb 26 11:12:03 CET 2003


>> [...]
>
> Hey, this is then a very good reason to implement
> a restricted array object. You just plug it into
> the frame as its stack, and it will crash when
> it feels abused. :-)
>
> ciao - chris

I don't know if this is in line with Christians comment, but I'd like to make 
a kind of proposal.
Until now, I'm very uncomfortable with the way we are implementing the 
stdobjspace. I have the feeling (there it is, this kind of discussion 
shouldn't be based on "feelings") that our implementation is somewhat 
circular, since we are using real Python objects to base our implementation 
of  PyPython objects on.
I'd rather have the notion of an external library our internal 
building blocks are coming from.
To make it more clear what I mean, I'll describe, what I have in mind with 
"numbers".
During the last few days, there was (is) an discussion on c.l.p about float 
arithmetic and some problems, one can run into. In that discussion, the 
following paper was mentioned: 
http://www2.hursley.ibm.com/decimal/decarith.html
It describes a number implementation that is compatible with "floats" and 
"ints". To make it short, a number is a triple (sign,coefficient,exponent)
whereas the exponent is a base 10 exponent.
0.25 thus could be written as (+,25,-2)
The paper goes on in describing all the operations, exceptions, etc. that are 
needed to implement a number library based on that number model.

The way, Python numbers are implemented at the moment, is to take the low 
level C "numbers" and wrap them as good as it gets and add a lot of code 
where things are missing.

I'd rather take a usefull number implementation and just wrap that (and 
translate only the exceptions, errors).

In order to implement such a number scheme, we'd need of course some notion 
of  bit fields.

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.

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?

Cheers

Stephan


More information about the Pypy-dev mailing list