D vs VM-based platforms

Bill Baxter dnewsgroup at billbaxter.com
Mon Apr 30 14:08:45 PDT 2007


Walter Bright wrote:
> Jan Claeys wrote:
>> And I think in the case of dynamic languages like Python, a JIT-compiler
>> often can create much better code at run-time than a compiler could do
>> when compiling it before run-time.
> 
> That's the theory. In practice, Python programmers who need performance 
> will develop a hybrid Python/C++ app, with the slow stuff recoded in C++.

In practice with Python I think what happens is more like:
1) make sure you're not doing something stupid.  If not ...
2) try psycho (a kind of JIT) (http://psyco.sourceforge.net).  If that 
doesn't help (it never has for me)...
3) rewrite slow parts in pyrex 
(http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/).  If that's 
not feasible then...
4) rewrite it as a native code module with Boost::Python or SWIG or just 
using the raw C API.  Or write a native shared library and use ctypes 
(http://python.net/crew/theller/ctypes/) to access it.

If you're doing numerical code then there are a couple of things you can 
try before resorting to rewriting.   numexpr 
(http://www.scipy.org/SciPyPackages/NumExpr) and scipy.weave 
(http://www.scipy.org/Weave).

And now of course you also have the option of rewriting the slow parts 
in D, thanks to Kirk.

--bb



More information about the Digitalmars-d mailing list