[Cython] calling gmp automatically

Ondrej Certik ondrej at certik.cz
Tue Dec 23 10:56:47 CET 2008


Hi,

currently Cython converts all "ints" as int32 in C (right?).

How difficult would be to improve Cython, so that it can automatically
convert all ints to gmp calls, so that one can use arbitrary integers?

Or to put the question differently, obviously, for most of my codes I
just need int32 and enjoy the speedups. However, sometimes it's handy
to use arbitrary ints, and since in Python both of it is just "int"
(resp. long in py2.6) --- what is the best way to have both?

Of course, one can call let's say gmpy directly from Python or Cython
and then all would be fine. But I think it would be easier if one can
just use Python integers and be done with it. And then just
(optionally) run it through Cython (let's say in pure Python mode) and
enjoy the speedups for free.

Ondrej


More information about the Cython-dev mailing list