[Psyco-devel] RE: [Numpy-discussion] Interesting Psyco/Numeric/Numarray comparison
falted at openlc.org
Fri Feb 7 09:46:04 CST 2003
A Dimecres 05 Febrer 2003 17:53, Tim Hochberg va escriure:
> However, for small arrays it seems that you're likely to
> be fighting the function call overhead of Python unless you go
> completely, or nearly completely, to C. But that would be a shame as it
> would make modifying/extending numarray that much harder.
For this task may be is worth to consider using Pyrex
(http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/) for that. From the
"""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."""
i.e. if you have code in Python and want to accelerate it, it's quite more
easy moving it to Pyrex rather than C, as Pyrex has Python syntax. In
addition, it lets you call C routines very easily (just declaring them) and
provide transparent access to variables, functions and objects in Python
namespace. Apart from the standard Python loop statement, Pyrex introduces a
new kind of for-loop (in the form "for i from 0 <= i < n:") for iterating
over ranges of integers at C speed, that can, for sure, be very handy when
optimizing many numarray loops.
Another advantage is that Pyrex compiles their own code to C and you can
distribute this C code in your package, without necessity to force the final
Pyrex extension user to install Pyrex (because it's just a kind of
compiler). I've been using it for more than six months and it's pretty
stable and works very well (at least for UNIX machines; I don't have
experience on Windows or OSX platforms).
Just my two cents,
More information about the Numpy-discussion