A quick introduction to psyco: The Python Compiler

Download Report

Transcript A quick introduction to psyco: The Python Compiler

A quick introduction to
psyco: The Python Compiler
Geoff Davis
Triangle ZPUG
December 6
What is psyco?

Open source python compiler
–


http://psyco.sourceforge.net
Very easy to use
Only works on 32-bit x86 processors
–
(or 64 bit in 32-bit compatibility mode)
How to use psyco

Quick overview:
–
–
import psyco
psyco.full()

That’s it!
psyco then takes over

DEMO

Play nice with Macs


If distributing code for mixed platforms, put
code in a try block:
try:
–
–

import psyco
psyco.full()
except:
–
pass
Use psyco selectively


psyco tries to compile everything
Not always useful
–
–
–

Compilation overhead
Uses lots of memory
Disables pdb
Can use psyco more selectively
Precision psyco

Can tell psyco to compile individual functions
–
–

Can have both compiled and uncompiled versions:
–

E.g. SpeedPack
Profiled everything in CMF, then compiled slowest methods
with psyco
fastfunction = psyco.proxy(slowfunction)
DEMO
Plug for 10 minute talks


Easy to put together! Took me 1 hour
Lots of stuff would be useful in this format
–
–
–
–


Editors / IDEs
Debugging tools
Plone/Zope products
Pure python products
No need for a huge, involved presentation
Please volunteer!