Future division detection
Christopher A. Craig
com-nospam at ccraig.org
Thu Nov 1 15:03:57 CET 2001
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.
Christopher A. Craig <com-nospam at ccraig.org>
More information about the Python-list