[Python-Dev] First cut of pyc2pasm released

Simon Cozens simon@simon-cozens.org
Sun, 16 Dec 2001 21:14:05 +0000

I hope you do not mind another brief Parroty interlude. If you're sick
of that kind of thing, I apologise, I'm not trying to poach your time, so
excuse me.

But! With the 0.0.3 release of Parrot list week, we've got sufficiently
powerful that it's sensible to think about running other languages'
bytecode on the Parrot VM. (Converting the bytecode alone saves the
hassle of writing a compiler, which is the difficult bit.)

So naturally, I started with Perl. I think that lasted for about half an
hour before I ran away screaming. Don't get me wrong, I like Perl, I
just wouldn't like to turn its op tree into anything sensible. So I
thought I'd show the buggers.

Python's bytecode is nice and straightforward, and dis.py turns it into
relatively simple assembly. The operations that it needs, Parrot
provides, even things like set_lineno and rot_four. It was only a matter
of time before I could disassemble Python bytecode and put it together
into Parrot assembly. 

http://archive.develooper.com/perl6-internals@perl.org/msg07040.html is
about as far as I got. It works. It runs "Hello World" and things
slightly more complex, and it groks simple variable manipulation.
It wouldn't be much hassle to add control structures.

As a slight disclaimer, the variable classes [1] it uses - PythonInteger
and so on - don't actually exist, but you can fake it by changing the
outputted assembler code to use the ones that Parrot provides. I'm going
to work on providing Python types in the core Real Soon Now, tuit

Anyway, there it is. Enjoy it. If you want to work on it, feel free;
if you want to take it and rewrite it in Python, then I'd be honored.
Whatever, it's out there, and we're serious about making Parrot work
for Python. (Or is it the other way around..? ;)


[1] One of Parrot's internal data types is the Parrot Magic Cookie,
something which is not a million miles distant from a PyObject. You
define PMCs by filling in a standard structure of manipulator methods,
just like in Objects/*object.c. 

Hubris is when you really do have it, enough so only the gods slap you
down. Pretentiousness is when you don't have it, and everyone slaps
you down. Arrogance is somewhere in between. 
    - Thorfinn