O'Reilly Open Source Convention
oreilly.comO'Reilly Network
Conferences International Safari: Books Online

Arrow Home
Arrow Registration
Arrow Speakers
Arrow Keynotes
Arrow Tutorials
Arrow Sessions
Arrow At-a-Glance
Arrow BOFs
Arrow Events
Arrow Exhibitors
Arrow Sponsors
Arrow Hotel/Travel
Arrow Venue Map
Arrow See & Do
Arrow Press
Arrow Mail List
Kids World

From the Frontiers of Research to the Heart of the Enterprise
O'Reilly Open Source Convention
Sheraton San Diego Hotel and Marina
July 22-26, 2002 -- San Diego, CA



Psyco, the Python Specializing Compiler
Armin Rigo, Université Libre de Bruxelles

Track: Python
Date: Wednesday, July 24
Time: 4:30pm - 5:15pm
Location: Marina IV

Dynamically typed languages like Python give a great flexibility whose cost is an often-poor algorithmical performance. The Psyco project shows that it is nevertheless possible to execute Python code at speeds approaching that of fully compiled languages. Preliminary results show potential speed-ups ranging from 2 to 100 times, depending on the source code.

Psyco is an extension module for the classical Python interpreter. It is not a substitute for it, and it cannot statically compile Python sources into machine code. It transparently emits machine code at run-time, like Java’s just-in-time compilers; but unlike these, Psyco dynamically tries to specialize the emitted code to the situation actually found at run-time. Specialization means that the machine code only works on Python objects satisfying additional constraints, like being of a given type. Its dynamic nature means that a differently specialized version of the same code can later be emitted if objects are found that satisfy different constraints. Each version can be almost as optimized as if it had been written in a statically typed language like C.

Besides the obvious performance gains, the main interest of Psyco is to show and develop techniques for incremental meta-level optimizations. These techniques allow it to support arbitrary Python constructs and C extension modules, even the ones it does not know about -- by reverting to the classical C implementation if needed. They could be used in a wider range of settings, from interpreters for other languages to OS design.

Download presentation file

oreilly.com Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies | Privacy Policy

© 2001, O'Reilly Media, Inc.