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

SI units are a standard that was kind of imposed top down on the computer science community. But we learned to use KB MB so why no keep the defacto standard we already have? Kibibytes and mibibytes were never really adopted. 1K == 1000 1KB == 1024 1M == 1000**2 1MB == 1024**2 Suffixes, simple. int_value = 8M float_value = 8.0M or float("8M") fraction_value = Fraction(1M, 8) or Fraction("1M/8") decimal_value = Decimal("1.2345M") Suffixes are by definition at the end of a literal. So 1E1E == 1E1 * 1E

Just to mention, these K M G suffixes are dimensionless. They can be used simply out of convenience, like 4K is a shorthand for 4000. And 9G is definitely easier to write and *therefore less prone to error* than a full literal. Dimensional analysis is fine but not the only reason to add these. pozdrawiam, Arkadiusz Bulski 2016-08-27 11:04 GMT+02:00 Arek Bulski <arek.bulski@gmail.com>:

On 27 August 2016 at 23:39, Arek Bulski <arek.bulski@gmail.com> wrote:
I dispute "less prone to error". Like it or not, there are a lot of people who would interpret "4K" as 4096. You can argue whether they are right or wrong all you like, but the fact remains that 4K is open to misinterpretation in a way that 4096 or 4000 is not. The (minimal) convenience of being able to write 4K rather than 4000 doesn't, in my mind, outweigh the risk. 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. Paul

On Sun, Aug 28, 2016 at 11:37:00AM +0100, Paul Moore wrote:
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

Just to mention, these K M G suffixes are dimensionless. They can be used simply out of convenience, like 4K is a shorthand for 4000. And 9G is definitely easier to write and *therefore less prone to error* than a full literal. Dimensional analysis is fine but not the only reason to add these. pozdrawiam, Arkadiusz Bulski 2016-08-27 11:04 GMT+02:00 Arek Bulski <arek.bulski@gmail.com>:

On 27 August 2016 at 23:39, Arek Bulski <arek.bulski@gmail.com> wrote:
I dispute "less prone to error". Like it or not, there are a lot of people who would interpret "4K" as 4096. You can argue whether they are right or wrong all you like, but the fact remains that 4K is open to misinterpretation in a way that 4096 or 4000 is not. The (minimal) convenience of being able to write 4K rather than 4000 doesn't, in my mind, outweigh the risk. 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. Paul

On Sun, Aug 28, 2016 at 11:37:00AM +0100, Paul Moore wrote:
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
participants (3)
-
Arek Bulski
-
Paul Moore
-
Steven D'Aprano