[Python-Dev] Future division detection

Christopher A. Craig com-nospam@ccraig.org
01 Nov 2001 09:03:57 -0500


I am in the process of porting my cRat module to take advantage of
some of the new features in Python 2.2 (and possibly making a patch
out of it to address PEP239 (though not for Python 2.2 obviously)).

While doing this I was thinking that I would change true_division on
ints and floats to return a rational and change the rational code to
return a long if the denominator is 1.  This works great, except that
if future division is off then rationals can suddenly become longs and
do not automatically cast back.  This makes it virtually impossible to
guarantee a correct result to nearly any rational computation that
involves a division.  

So I wanted to know if there is some way to detect, at the object
level, if the CO_FUTURE_DIVISION feature is active.

rational'ly y'rs

-- 
Christopher A. Craig <com-nospam@ccraig.org>