ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
Re: [Tutor] Compiling Python to Native Machine Code
by Danny Yoo other posts by this author
Sep 2 2003 10:36AM messages near this date
Re: [Tutor] Compiling Python to Native Machine Code | [Tutor] for x in myClass
On Tue, 2 Sep 2003, Marc Barry wrote:

>  Is it possible to compile Python directly to native machine code? The
>  reason I ask is because I am using Python to do some pretty intensive
>  simulations that take anywhere between 10 minutes and a few hours to
>  run. I assume that if I could compile it directly to machine code that
>  this may speed up my simulation times.

Hi Mark,

At the moment, no.  You may be able to get some substantial performance by
using Psyco, though:

    http://psyco.sourceforge.net/

If your code is particularly algorithmic in nature, Psyco might do wonders
for it.


If you can identify which parts of code are performance hogs, we have a
few options.  For example, it might be possible to recode those
performance-critical pieces in another language --- like C or OCaml ---
and bind those recoded pieces to Python.

If you want to take this route, there's good prior work that's gone into
this.  *grin* People have written several popular tools to help do this
"extending"; you may want to look into Scientific Python's "weave" module:

   http://www.scipy.org/

as well as SWIG:

    http://www.swig.org/



>  Does anyone have any experience with doing this? Would there be any
>  significant gains?

It really depends on the algorithms that you are using.  Do you mind
showing us a sample of the kind of calculations you're doing?  And do you
have a "profile" of your application?  Profiles can help pinpoint busy
areas of the code.  Here's documentation to Python's profiler:

    http://www.python.org/doc/lib/profile.html


Good luck to you!


_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Marc Barry
Alan Gauld
A.M. Kuchling
Danny Yoo

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved