[pythran] gmp

  • From: Brunet Pierrick <pierrick.brunet@xxxxxxxxxxxxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Sat, 27 Oct 2012 15:54:45 +0200


About last commit, I did some modification as I never tested to use a long as pythran input specification. In the code, we need to use mpz_class as a constructed type to have a correct behaviour.
Also, I fix another issue un the conversion from pylong to mpz_class.

I tested the code below and get an error:

#export pythran test(long)
def test(a)
    for i in xrange(a):

Because xrange doesn't support long as input parameter. It looks like python doesn't support either.

About profiling, I did some test using the binamial law with : 10 by 60. Result look good and we have almost the same ratio with others numbers. I just need to find some others bench

In [4]: %timeit test1.test(10,60)
100000 loops, best of 3: 5.26 us per loop

In [5]: %timeit test2.test(10,60)
100000 loops, best of 3: 5.32 us per loop

In [6]: %timeit test3.test(10,60)
100000 loops, best of 3: 11.5 us per loop

Finally, we have another error now:

if we define a long num : a = 1111111111111L
and add a float: b = a +2.5
the result is b = 1111111111113L
Pythran doesn't care about the value after the point.
Issue comme from Assignable specification but we can't do this in another way as gmp have some limitation about Templates :

The solution can be to concidere long as mpf_class instead of mpz_class. But if we keep the same precision, we will lose some performance.

Have a good week end.

Other related posts: