Wednesday, September 19, 2007

Pynie - the Parrot-based Python Interpreter

Some weeks ago the DFW Pythoneers usergroup had a presentation by our own Patrick Michaud about his work getting a Python interpreter on top of the Parrot bytecode VM. Recently I've started playing with it, and found it rather easy to get up and running.

Don't get too excited though - plenty of Python-specific functionality is missing - it basically lacks the standard library and has stubs for most of the Python statements. If there are others into language internals who would like to work on this, I would like to coordinate with them. Here in Dallas we're considering arranging a special event, to meet with Patrick and sprint on Pynie. I'd suggest if you're curious to go download and install it to see if it is something you can get into.

To get you to the good stuff, here are the basic steps:

# mkdir ~/ParrotWork
# cd ~ ParrotWork
# svn co parrot
# cd parrot
# perl
# make
# make test (to run the test suite)
# cd languages/pynie
# make
# ../../parrot pynie.pbc

Although there are packages for Debian, Gentoo and so forth, I suggest working with the latest in subversion because of Parrot is rapidly changing in development.

One neat aspect is that you can compile your Python programs into x86 code, using the Parrot JIT:

# ../../parrot --target=PIR -o yourhellopgm.pir
# ../../parrot -o yourhellopgm.pbc yourhellopgm.pir
# ../../parrot -o yourhellopgm.o yourhellopgm.pbc
# cd ../..
# make EXEC=languages/pynie/yourhellopgm exec
# ./yourhellopgm

There is interesting reading about Parrot internals in general in the directory ~/ParrotWork/docs, just use "perldoc intro.pod" to get started. It kept me up all night reading. ;-)

And for the Python-specific portions of the source, check out:

builtins/ (implementation of Python datatypes)
parser/ (lexer/parser definitions to take apart Python source)
PAST/ (Parrot Abstract Syntax Trees to generate bytecode)



The Daily Reviewer said...


Congratulations! Your readers have submitted and voted for your blog at The Daily Reviewer. We compiled an exclusive list of the Top 100 python Blogs, and we are glad to let you know that your blog was included! You can see it at

You can claim your Top 100 Blogs Award here :

P.S. This is a one-time notice to let you know your blog was included in one of our Top 100 Blog categories. You might get notices if you are listed in two or more categories.

P.P.S. If for some reason you want your blog removed from our list, just send an email to with the subject line "REMOVE" and the link to your blog in the body of the message.


Angelina Mizaki
Selection Committee President
The Daily Reviewer

Doktor said...

This sounds great. I would like to do what I can to help build a team to enable it to go from Python to Scala.
Doktor Stovall Foundation