[Pyrex] Question, plus suggestions for improvement?

Josiah Carlson jcarlson at uci.edu
Wed Aug 2 21:19:20 UTC 2006


"Bill Mill" <bill.mill at gmail.com> wrote:
> I think your post hit while I was writing mine. Thanks very much for
> all that effort.

No problem.

> I have to report, unfortunately, that my working version of your code,
> which I dubbed PermuteJ, ends up being a bit slower than Permute2. My
> guess is that the cost of transferring the C array to the Python one
> for every iteration outweighs the benefit of the quicker C accesses,
> but I have not really tested that assertion.
> 
> (I posted my modified version of your code at
> http://www.bigbold.com/snippets/posts/show/2353 ).

It is unfortunate that it doesn't happen to be faster for your input. 
On the upside, this particular method should improve the speed of
permuting objects whose comparison is relatively slow (classes
implemented in Python, nontrivial strings, tuples, and other containers),
and it should work for arbitrary input.

One thing that may improve speed generally is a replacement of the
assignments with PyList operations, or even direct pointer manipulation;
as this algorithm shouldn't result in refcount changes.


 - Josiah




More information about the Pyrex mailing list