[Python-ideas] SI scale factors in Python

Ian Kelly ian.g.kelly at gmail.com
Thu Aug 25 02:11:15 EDT 2016


On Wed, Aug 24, 2016 at 11:57 PM, Greg Ewing
<greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>>
>> If units are retained, what you have is no longer a simple number, but
>> a value with a unit, and is a quite different beast. (For instance,
>> addition would have to cope with unit mismatches (probably by throwing
>> an error), and multiplication would have to combine the units (length
>> * length = area).)
>
>
> And that can be surprisingly tricky. For example, newtons
> times metres equals joules -- but *only* if the force and
> the distance are in the same direction, otherwise it's
> torque rather than energy and the units are just
> newton-metres.

I'd say that it more accurately depends on whether the distance
represents a displacement or a position of application. If one pushes
a shopping cart off-center, that produces both work and torque, with
different "distance" vectors for each.

Analytically, one is a cross-product and the other is a dot-product.
The unit matching engine would have to understand the difference and
know which one is being applied in the calculation.


More information about the Python-ideas mailing list