for / while else doesn't make sense
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon May 23 03:09:56 EDT 2016
On Monday 23 May 2016 03:25, Random832 wrote:
> Why shouldn't Python do this?
>
> Imagine some future version of Python:
>>>> x = 2/3
>>>> x
> (2/3)
>>>> type(x)
> <class 'rational'>
You would have a lot of trouble convincing Guido that this was a good idea,
because that's what ABC used to do, and it was a performance killer, as well as
being horrible to work with.
Rationals like 2/3 are fine. But the trouble is, by the time you've done a
handful of calculations, you've probably got something like
5529748264768821/18014398509481984
and after a few dozen calculations you might have something like:
391303115027894573050315966944902650883330501592661514878103414119479331609846605406995557395414953/14109433351889544757158673468211253755455976544516272594484740551000078367597300074881469573563940864
and it just keeps getting worse and worse.
For bonus points, without converting to floats, can you tell which of of the
two numbers is bigger by sight?
--
Steve
More information about the Python-list
mailing list