Dumb python questions

Alex Martelli aleaxit at yahoo.com
Sun Aug 19 06:39:13 EDT 2001


"Paul Rubin" <phr-n2001 at nightsong.com> wrote in message
news:7x1ym8jyuk.fsf at ruckus.brouhaha.com...
    ...
> The numbers I actually want to use are closer in magnitude to 7**777
> rather than 7**77777, if that matters.  I'd prefer to avoid using
> a C library.  If I use one, gmpy should do the job.  I've timed
> Python's arithmetic as around 10x slower than gmpy, which is
> quite respectable since gmpy's inner loops are carefully tuned
> assembly code, and this kind of arithmetic is hard to do efficiently

Unfortunately, gmpy just relies on GMP, which in turn only has the
carefully tuned machine-language inner loops on a few selected
architectures -- elsewhere they're replaced by carefully-coded C
which, indeed, cannot be quite as fast.  I noticed because at first
I only had a C-only version of GMP for Windows/VC++6; when I
moved to a GMP version including the port of the assembly part,
performance soared [and another boost came from switching to
an Athlon chip from a pure-Intel one -- so I sort of suspect that
there should probably be different machine-language inner loops
for top performance on Athlon vs Pentium3, given different
caching, branch-prediction, etc, etc].  Unfortunately I did no
careful measurements (mea culpa!) so thanks for giving them...

> in portable C.  Python's arithmetic is around 100x faster than
> perl's Math::BigInt.

Interesting -- I guess (and hope, because competition is what
keeps everybody on their toes:-) that some devoted Perlist is
already busy recoding their big-int module for performance?-)


Alex






More information about the Python-list mailing list