[Python-ideas] Python Numbers as Human Concept Decimal System

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Mar 6 00:24:46 CET 2014


On 5 March 2014 22:36, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Steven D'Aprano wrote:
>>
>> (By the way, I think it is somewhat amusing that Python not only has a
>> built-in complex type, but also *syntax* for creating complex numbers, but
>> no built-in support for exact rationals.)
>
> I gather that Guido's experiences with ABC have led him
> to believe such a feature would be an attractive nuisance.
> Rationals have some nasty performance traps if you use
> them without being fully aware of what you're doing.

I've read statement's to that effect but they were specifically about
having rational as the *default* mode for integer division which I am
not suggesting.

It's already possible to opt-in to using Fractions so that rationals
are used for division. Currently you have to import a module and write
F(1, 7) or F('1/7') everywhere in your code. If it were possible to
write 1/7F or 1/7r or whatever then I've personally written code where
I would have used that so that it would be easier to read, would look
more natural with syntax highlighting etc.


Oscar


More information about the Python-ideas mailing list