Creating a PYD file
stefan_ml at behnel.de
Mon Aug 23 13:02:01 CEST 2010
Rony, 19.08.2010 21:41:
> The question actually is, is a PYD file created from C faster then a
> PYD file from Pyrex ?
Most likely, yes.
However, when comparing to Cython instead of Pyrex, the answer really
depends on your code. Cython cannot be faster than the equivalent C code,
simply because it generates C code. However, if the Python call overhead
matters (e.g. in thin wrappers around simple C functions), Cython easily
wins because it uses various tweaks that you simply wouldn't write in your
own C code. If the overhead can be ignored, hand tuned C code wins often
but not always, with the obvious drawback of being much harder to write and
much longer in lines of code.
Generally speaking, if you can avoid it, don't write the extension in C.
You'll have your Cython code hand optimised long before your C code is even
close to running. And in the long run, the maintenance cost will always be
the dominating factor anyway.
More information about the Python-list