[Python-ideas] real numbers with SI scale factors

Brendan Barnwell brenbarn at brenbarn.net
Sun Aug 28 23:26:38 EDT 2016


On 2016-08-28 18:44, Ken Kundert wrote:
> When working with a general purpose programming language, the above numbers
> become:
>
>      780kpc -> 7.8e+05
>      108MPa -> 1.08e+08
>      600TW  -> 6e+14
>      3.2Gb  -> 3.2e+09
>      53pm   -> 5.3e-11
>      $8G    -> 8e+09
>
> Notice that the numbers become longer, harder to read, harder to type, harder to
> say, and harder to hear.

	You've continually repeated this assertion, but I don't buy it.  For 
the general case, exponential notation is easier to read because you can 
always see exactly what the exponent is as a number.  To read SI units, 
you have to know all the SI prefixes.  This may well be common within 
scientific communities, but to say that it is "easier" is really a bit 
much.  The same is true of "harder to type".  "kpc" is three characters; 
e+5 is also three (note that you don't need to write e+05), and one of 
those is a number that transparently indicates how many places to move 
the decimal, whereas all of the letters in "kpc" are opaque unless you 
already know what the number is meant to represent.

	If you have concrete evidence (e.g., from actual user experience 
research) showing that it is across-the-board "easier" to read or type 
SI prefixes than exponential notation, that would be good to see.  In 
the absence of that, these assertions are just doubling down on the same 
initial claim, namely that adding SI units to Python would make things 
more convenient *for those using it to compute with literally-entered 
quantities in SI units*.  I quite agree that that is likely true, but to 
my mind that is not enough to justify the disruption of adding it at the 
syntactic level.  (Unless, again, you have some actual evidence showing 
that this particular kind of use of numeric literals occurs in a large 
proportion of Python code.)

 > Before we expend any more effort on this topic, let's put aside the 
question of
 > how it should be done, or how it will be used after its done, and 
just focus on
 > whether we do it at all. Should Python support real numbers specified 
with SI
 > scale factors as first class citizens?

	My current opinion is no.  There are lots of things that are common. 
(Should we include a spellchecker in Python because many people 
frequently make spelling errors?)  The fact that SI units are de rigeur 
in the physical science community isn't enough.  I would want to see 
some actual attempt to quantify how much benefit there would be in the 
PYTHON community (which of course includes, but is not limited to, those 
using Python for physical-science computations).

-- 
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is no 
path, and leave a trail."
    --author unknown


More information about the Python-ideas mailing list