[pypy-dev] Confused about RPython

Christian Tismer tismer at stackless.com
Fri Jul 29 15:34:36 CEST 2005


Niklaus Haldimann wrote:

...

> I think the buffer interface is a no-brainer, but maybe I'm missing 
> something. Our buffer type is written at applevel, we have no obligation 
> at all to emulate CPython's C-based buffer interface. We can define our 
> own interface, and in fact the current buffer implementation sort of 
> does that. Hacking array support into the current buffer will be a 
> matter of 2-3 lines of code, AFAICT. More effort would be a waste of 
> time anyway, as buffer is as good as deprecated. ;)

Sounds reasonable.
Actually I didn't look too closely into the array module myself,
I was just repeating what another guy reported when trying to
implement it. So it might be easier than I expcetged.

...

> I see, that really clears things up a bit. Is it correct to say that 
> geninterping such an "applevel RPython" module guarantees that the 
> resulting interplevel code can in fact be translated? That sounds a bit 
> too much like magic to me.

No, it doesn't. It tells you that the flow space is happy with
your code, but still there may be issues with annotation I think.
And stuff like producing an infinite recursion is not detected
at all. For instance, we had code that relied on applevel in
a way that the implementation called into the interpreter for
something that then goes back to the implementation which...

So I'd say geninterping is a necessary but not sufficient condition.

...

> OK. Just to be a bit more explicit about this, I do something like:
> 
>  >>> t = Translator(my_rpython_function)
>  >>> t.annotate([int])
> 
> And check that the inferred return type is not SomeObject. This 
> basically means that flowspace and rtyper are happy, right? What I don't 
> understand ATM is where the translator will get the above "[int]" 
> annotation hint from in the real world ...

You are giving it the hint to have some reasonable starting point
for testing, assuming that this assumption generally holds.

In the real world, everything and all of PyPy is run through the
annotator, which re-iterates stuff until it ends up with
a proven interface, or it has to give up with someobjectness.
So the realanalysis depends on whether your implementation
is really called in the right way, all over PyPy.

ciao - chris
-- 
Christian Tismer             :^)   <mailto:tismer at stackless.com>
tismerysoft GmbH             :     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 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
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