An Efficient Scalar Class in Python

uymqlp502 at uymqlp502 at
Tue Mar 14 03:14:01 CET 2006

A Python class called "scalar" was designed to represent physical
scalars and to eliminate errors involving implied physical units (e.g.,
confusing angular degrees and radians). The standard arithmetic
operators are overloaded to provide syntax identical to that for
built-in numerical types. The scalar class allows the user to easily
define a set of appropriate physical units for any particular
application or domain, and the units used internally are based on those
selected by the user. Once an application has been developed and
tested, the units can easily be switched off, if desired, to achieve
the execution efficiency of built-in numerical types (which can be two
orders of magnitude faster). The scalar class can also be used for
discrete units to enforce type checking of integer counts, thereby
enhancing the built-in dynamic type checking of Python.

I think you'll like it. Check it out and let me know if I'm right. And
let me know if you have any problems. I've tested it to some extent,
and I think it's in good shape, but I'd like to get some feedback from
other users before I upgrade the beta version to a 1.0 release. Thanks.

Go to to download the user guide and the

More information about the Python-announce-list mailing list