crat rational module

WHAT:

This module allows Python to use rational numbers.  It was written in C but
should compile on all platforms for which CPython compiles.

This modules was designed for both portability and speed.  I tried to only
use functions that are universally supported by C, or that are included in
the CPython distribution, thus ensuring that the module will compile on all
CPython platforms.  I haven't actually compiled it on every CPython
platform (or more than about three of them), but I think it should work.
Feel free to write me at com-nospam@ccraig.org if you find that it doesn't
(though I might not be able to help, I will try).


HOW:

type:
python setup.py install 

to install.  type 
python setup.py install --help 

for options

WHY:

Why would I write another rational module when the name Yet Another Rational
Number module (yarn.py) is already taken?  

speed.

The bane of any rational number system is its gcd function.  Every arithmetic
operation except non-modular exponentiation requires that gcd be called
(actually on several modules gcd is always called, even if it doesn't need to
be), and gcd is much slower than the surronding math.  Most gcd functions
(every Python module I've seen) rely on Euclid's algorithm.  This algorithm
has very few loops, but depends on division, which for Python longs can be
very slow.

My gcd routine beats Euclid's method by about 90% for two 1024 bit numbers,
50% for two 5 bit numbers, or 50% for one 1024 bit number and one 5 bit
number.  

I further increased speed by using methods of doing arithmetic that try very
hard to run gcd with the smallest possible operands.  

For more information on the math used and its rationale read README.MATH

