[Python-ideas] SI scale factors alone, without units or dimensional analysis

Steven D'Aprano steve at pearwood.info
Sun Aug 28 08:22:49 EDT 2016


On Sun, Aug 28, 2016 at 11:37:00AM +0100, Paul Moore wrote:

> And if you're concerned about larger numbers, such as 16000000000, and
> the need to count zeroes, I'd argue that you should name such a
> constant - and Python 3.6 will allow you to write it as 16_000_000_000
> in any case, making things completely clear.

Since we're talking about integers, you can write 16*10**9 and the 
keyhole optimizer in recent versions of Python will do the maths for you 
at compile-time.

Or just write 16e9 and use a float.

By the way, I see at least one language (Frink) uses EE for exact 
integer exponents:

16e9 => float 16.0*1.0**9

16ee9 => int 16*10**9

Anyone think this is a good idea?



-- 
Steve


More information about the Python-ideas mailing list