[Pyrex] Pyrex v Psyco
John Machin
sjmachin at lexicon.net
Mon Jun 19 02:26:17 UTC 2006
On 19/06/2006 8:59 AM, Philip Smith wrote:
> Hi
>
> First of all thanks to Greg for Pyrex (which I have come to very
> recently and which will certainly make wrapping libraries easier)
>
> I've been looking for an alternative to Psyco for distributing Python
> apps to other platforms than Win32 - however (while not being in general
> a 'speed' junkie) I don't want to sacrifice performance.
>
> I've been trying Pyrex out on a small text search programme which uses
> the Boyer-Moore algorithm and which I have adapted to search for all
> occurrences of a string in the given text.
>
> With algorithmic improvements I managed something like a 10 fold
> increase in speed performance and Psyco gives me another 10 fold
> increase. I've read all the tips and tricks re: Pyrex I can find and
> tried to implement them but I can't seem to replicate the performance
> enhancement over Psyco which the Pyrex test suite demonstrates - in fact
> Psyco wins hands down every time.
>
> Am I (as a newcomer) doing soething obviously wrong or is there
> something about this code that means one wouldn't expect particularly
> fast execution???
>
> Thanks
>
> Phil
>
> This is my pyx file:
>
> -----------------------------------
>
>
> cdef extern from "Python.h":
>
> cdef object PySequence_GetItem(object o, int i)
Well as sure as the supreme being made little apples, pysco ain't
faffing about with PySequence_GetItem()!!!
You need to get a cdef (char *) pointing to the start of each of your
string args, and a cdef int containing the length of each, then proceed
as if you were writing the thing in C.
More information about the Pyrex
mailing list