Rationals?

Mike Meyer mwm at mired.org
Thu Nov 18 12:58:45 EST 2004


Tim Peters <tim.peters at gmail.com> writes:

> [Mike Meyer]
>> With the decimals and the unification of int and long coming, it's
>> natural (for me, anyway) to wonder how much interest there is in a
>> rational type.
>
> It is natural to wonder <wink>.
>
>> There are two PEPs (239 and 240), and the Guido rejects them as
>> no one seems interested in doing the work, but points out that the
>> python distribution comes with examples/Demo/classes/Rat.py.
>>
>> I propose - in the spirit of "batteries included" - that Rat.py be
>> cleaned up some (mostly to take advantage of the union of ints and
>> longs)
>
> +0
>
>> and moved into the standard library.
>
> -1
>
>> Any good reasons not to do this?
>
> There's no reason not to clean it up.  But Rat.py belongs where it is
> regardless:  it *is* "a demo", too half-baked for the standard
> library.  There's a better implementation in the Python sandbox:
>
>     http://cvs.sf.net/viewcvs.py/python/python/nondist/sandbox/rational/

Cool. I knew there had to be some out there, but couldn't find one in
either PyPI or the cookbook. I picked on Rat.py because it was what I
found.

> Moshe left that behind going on 4 years ago now, as a prototype for
> PEP 239.  It's also far from being suitable for the standard library: 
> the PEP is more a sketch of an idea than a specification, the PEP
> needs to be accepted, the module needs real documentation, and it
> needs a test suite.

Actually, I don't like the two PEPs. Both include changes to the
language that would surprise programmers and non-programmers as well
as having a negative impact on performance. You should only get a
rational if you specifically ask for a rational.

And I'm aware that any "clean up" means writing real documenation and
a test suite, as well as fixing the code.

> leaky-AAA-cells-wasn't-"batteries-included"'s-intent-ly y'rs  - tim
>
> PS:  If you simply want to *use* a high-powered rational type,
> download gmpy and be happy tonight.

No - it's that rationals are available in a number of other
programming languages I use, and it seems strange that they would be
missing from a language that comes with "batteries included".

And yes, I am willing to do this work. But don't want to bother if
there's no chance of it getting into the standard library. Creating
yet another rational package outisde the standard library is pretty
pointless.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list