[Cython] Make positive int literals unsigned long?
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Aug 5 03:27:38 CEST 2008
Robert Bradshaw wrote:
> I think in general that is a good idea, but the problem is that
> PyLong_FromUnsignedLong is slower than PyInt_FromLong and produces python
> longs rather than python ints. One would need a special type (or flag) to
> indicate that the top bit can be assumed to be 0.
There could be a utility function that creates either an
int or a long depending on the value passed to it.
It might also be possible to choose between them at
compile time in the case of literals, although it would
be tricky because it would depend on sizeof(int) on
the target platform. Some kind of macro might be
able to do it.
--
Greg
More information about the Cython-dev
mailing list