"Dan Bishop" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: >> This version includes the input from various and sundry people. > Thanks >> to everyone who contributed. >> >> <mike >> >> PEP: XXX >> Title: A rational number module for Python > ... >> Implementation >> ============== >> >> There is currently a rational module distributed with Python, and a >> second rational module in the Python cvs source tree that is not >> distributed. While one of these could be chosen and made to conform >> to the specification, I am hoping that several people will volunteer >> implementatins so that a ''best of breed'' implementation may be >> chosen. > > I'll be the first to volunteer an implementation.
I've already got two implementations. Both vary from the PEP. > I've made the following deviations from your PEP: > > * Binary operators with one Rational operand and one float or Decimal > operand will not raise a TypeError, but return a float or Decimal. > * Expressions of the form Decimal op Rational do not work. This is a > bug in the decimal module. > * The constructor only accepts ints and longs. Conversions from float > or Decimal to Rational can be made with the static methods: > - fromExactFloat: exact conversion from float to Rational > - fromExactDecimal: exact conversion from Decimal to Rational > - approxSmallestDenominator: Minimizes the result's denominator, > given a maximum allowed error. > - approxSmallestError: Minimizes the result's error, given a > maximum allowed denominator. > For example, Part of finishing the PEP will be modifying the chosen contribution so that it matches the PEP. As the PEP champion, I'll take that one (and also write a test module) before submitting the PEP to the pep list for inclusion and possible finalization. If you still wish to contribute your code, please mail it to me as an attachment. Thanks, <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list