From: Francesc A. <fa...@op...> - 2003-02-07 17:45:05
|
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 website: """Pyrex lets you write code that mixes Python and C data types any way y= ou 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 mor= e 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) a= nd provide transparent access to variables, functions and objects in Python namespace. Apart from the standard Python loop statement, Pyrex introduce= s a new kind of for-loop (in the form "for i from 0 <=3D i < n:") for iterati= ng over ranges of integers at C speed, that can, for sure, be very handy whe= n 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 fi= nal 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, --=20 Francesc Alted |