gmp module

Alex Martelli aleaxit at yahoo.com
Tue Nov 7 15:00:05 EST 2000


"Andrew Kuchling" <akuchlin at mems-exchange.org> wrote in message
news:3dbsvrpvey.fsf at kronos.cnri.reston.va.us...
> "Alex Martelli" <aleaxit at yahoo.com> writes:
> > ExtensionClass (a part of Zope, but also released
> > separately) is, I think, what could help doing this.
> > But, in general, I don't think it's possible (or,
> > surely, not easy), while py_cpp does make it easy.
>
> I don't think ExtensionClass fully supports numeric behaviour, partly
> due to limitations in ExtensionClass and partly due to architectural
> issues in Python.  For example, ExtensionClasses don't support
> __radd__ & related methods.

Good point, thanks.


> The old GMP module could be dropped on top of Objects/longobject.c to
> make Python use GMP for all longs.  This worked for 1.4 and 1.5.2, but
> breaks in 2.0 because there are more C-level conversion functions,
> mostly for C's "long long" type, in 2.0, which obviously aren't

Yep, I struggled with that a bit (since gmpy is based on your
old GMP module, upgraded for GMP 3 and Python 2), then
decided to give it up (as far as gmpy is concerned) -- gmpy
has no ability to be substituted for longobject.c

> implemented yet.  Eventually I'll get around to checking if GMP 3.x
> adds interfaces that support long long.  I wonder if it would be

I haven't seen any in GMP 3.0.

> practical to require GMP for Python and just use its fancy and fast
> implementation of long integers instead of Python's simple and
> not-so-fast implementation.

Only if the Python team were willing to undertake the task of
making GMP build on every architecture supporting Python (at
least for the integer functions), since clearly the GMP team
has no interest in that.  GMP does not build 'out of the box'
on Windows with MSVC++, for example (not exactly an
inconsequential platform), and looking around for fixes for
that I found about a hundred requests and pleas for help for
it, and only one (1) guy (in Japan) who managed to build
GMP 3.0 on Windows/MSVC++ (and I can't read his Japanese
instructions on how to repeat this -- he also points to a
Belgian page which doesn't seem to exist any more -- but
fortunately he does have a binary GMP.LIB on his site that
I was able to use for gmpy purposes, although I think the
perfect-power checking function in particular is broken).

It might be less trouble to provide _either_ GMP use _or_
the built-in fall-back as a configuration option...


Alex






More information about the Python-list mailing list