[pypy-dev] Questions for Armin

Christian Tismer tismer at tismer.com
Sat Jan 18 22:43:17 CET 2003


Armin Rigo wrote:

...

> def my_function(a,b,c):
>   return a+b+c
> 
> the emitted machine code looks like what you would obtain by compiling this:
> 
> PyObject* my_function(PyObject* a, PyObject* b, PyObject* c)
> {
>   int r1, r2, r3;
>   if (a->ob_type != &PyInt_Type) goto uncommon_case;
>   if (b->ob_type != &PyInt_Type) goto uncommon_case;
>   if (c->ob_type != &PyInt_Type) goto uncommon_case;
>   r1 = ((PyIntObject*) a)->ob_ival;
>   r2 = ((PyIntObject*) b)->ob_ival;
>   r3 = ((PyIntObject*) c)->ob_ival;
>   return PyInt_FromLong(r1+r2+r3);
> }

[snipped all he good rest]

Just a little comment.
The above is what I like so much about the Psyco
ideas. Now consider the huge eval_code function,
wih its specializations in order to make operations
on integers very fast, for example.
With Psyco, these are no longer necessary, since
Psyco will find them by itself and create code like
the above from alone.

As another point, when re-implementing the Python
core objects in Python, there are many internal
functions which are called by the interpreter,
only. The datatypes pssed to those functions
will be almost always the same, and since the
functions aren't exposed otherwise, the first
time they are called will create their final
version, and the uncommon_case can be dropped
completely.
We just need to "seed" them with appropriate
primitive data types, and the whole rest
can be deduced with ease. That's what I eagerly
want to try and to see happen :-)

> I hope that these examples cast some light on Psyco.  I realize that this
> could distract people from the current goals of this project, and I apologize
> for that.  We should discuss e.g. "how restricted" the language we use for
> Python-in-Python should be...

Sorry, I couldn't resist it.

I will start to ask some questions in a different
thread.

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