Thanks for the fast reply!

On Wed, Oct 29, 2008 at 11:57 PM, Robert Bradshaw
<[EMAIL PROTECTED]> wrote:
> On Oct 29, 2008, at 11:08 PM, Case Vanhorsen wrote:
>
>> I help maintain the gmpy library and I've been experimenting with a
>> Cython-based wrapper for GMP. I've done simple performance tests with
>> an early version of the library and it is slower than the C-based gmpy
>> library. I compared object creation and addition times for Python
>> longs, gmpy, and gmpy3 (the experimental library). These are my
>> results, in seconds (code is below):
>>
>> create times
>> long:   2.25385284424
>> gmpy:   1.70728683472
>> gmpy3:  2.3947558403
>>
>> addition times
>> long:   3.03700900078
>> gmpy:   2.6448340416
>> gmpy3:  4.70184206963
>
> Interesting.
>
>> Do you have any suggestions for improving the performance?
>
> It looks like gmpy.c doesn't do any type checking for add, which
> could be a cause for concern (but also make things faster). Is this
> with cython-devel or the release version? The isinstance function
> will be much faster in the next release of Cython, as is the argument
> parsing, so that should help too. Probably the most significant thing
> you could do is construct the mpz class directly rather than call mpz
> () (e.g. see the PY_NEW macro at http://www.sagemath.org/hg/sage-main/
> file/3859ace86968/c_lib/include/stdsage.h for one way to do that).
> Also, type your "base" parameter to be an int in the __init__ method.
>
By changing "result=mpz()" to "result=PY_NEW(mpz)", the running time
for addition improved to ~4.0 seconds. I actually used the PY_NEW
macro from http://lists.copyleft.no/pipermail/pyrex/2007-November/002994.html.

I upgraded to the just posted beta release. No significant change.

>>
>> Thanks,
>>
>> Case

Thanks again,

Case
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to