[Python-ideas] SI scale factors in Python

Joao S. O. Bueno jsbueno at python.org.br
Thu Aug 25 05:55:10 EDT 2016


On 25 August 2016 at 06:06, Paul Moore <p.f.moore at gmail.com> wrote:
> On 25 August 2016 at 09:54, Ken Kundert <python-ideas at shalmirane.com> wrote:
>>     1G -> 1e+09
>>     1M -> 1e+06
>>     1k -> 1e+03
>
> While these suffixes are suitable for a scientific context, in a
> computing context, 1k=1024, 1M=1024*1024 and 1G=1024*1024*1024 make
> just as much, if not more, sense (and yes, I'm aware of Gigabyte vs
> Gibibyte).
>
> If "1M" were a legal Python literal,. I would expect a lot of
> confusion over what it meant - to the extent that it would hurt
> readability badly.
> Paul


So, the idea of adding fixed sufixes to the core language I regard as
awful - due to these and other considerations  -
But maybe, oen thign to think about is about "operatorless"
multiplication - jsut puting two tokens side by side, which currently
yieds a Syntax Error could call `__mul__`
(or a new `__direct_mul__` method on the second operator.

That would enable a lot of interesting things in already existing
packages like SymPy - and would allow a "physics measurements"
packages that would take care of the ideas on the starting of the
thread.

I certainly would be more confortable for mathematicians and other
people using Python in interactive environments such as iPython
notebooks.

But other than having this as a multiplication, I am against the whole thing.


More information about the Python-ideas mailing list