[Tutor] Compiling Python to Native Machine Code
Alexandre Ratti
alex at gabuzomeu.net
Fri Sep 5 11:02:44 EDT 2003
Hi Marc,
Marc Barry wrote:
> The type of algorithm I am using is the well known Dijkstra shortest
> path.
> I may have to look at implementing the Dijkstra algorithm portion of
> the simulation in C. Although, it would be a terrible waste of time if
> I didn't do any better than the 10% reduction I got using Psyco.
I don't know this algorithm, so maybe this suggestion won't apply, but
have you tried using Pyrex? Pyrex is a tool that takes Pythonic code as
input (basically Python + type declarations) and that outputs C
extensions. This might make it easier to test whether recoding tne
algorithm in C is worth it.
"Pyrex lets you write code that mixes Python and C data types any way
you want, and compiles it into a C extension for Python."
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
There is a usage example in this doc: /Python 201 -- (Slightly) Advanced
Python Topics/:
http://www.rexx.com/~dkuhlman/python_201/python_201.html#SECTION006400000000000000000
Cheers.
Alexandre
More information about the Tutor
mailing list