[Python-ideas] SI scale factors in Python
Xavier Combelle
xavier.combelle at gmail.com
Thu Aug 25 02:08:34 EDT 2016
On 25/08/2016 06:28, Ken Kundert wrote:
> All,
> I propose that support for SI scale factors be added to Python. This would
> be very helpful for any program that heavily uses real numbers, such as those
> involved with scientific and engineering computation. There would be two primary
> changes. First, the lexer would be enhanced to take real literals with the
> following forms:
>
> c1 = 1nF (same as: c1 = 1e-9 # F )
> c = 299.79M (same as: c = 299.79e6 )
> f_hy = 1.4204GHz (same as: f_hy = 1.4204e9 # Hz)
>
There is little difference (except that it ask for a syntax modification
which should be heavy weighted)
between this proposition and
c1 = 1*nF (same as: c1 = 1e-9 # F )
c = 299.79*M (same as: c = 299.79e6 )
f_hy = 1.4204*GHz (same as: f_hy = 1.4204e9 # Hz)
with correct definition of the constants in a library.
So a library would be welcome.
More information about the Python-ideas
mailing list