[PYTHON MATRIX-SIG] Handling null data points

Jody Winston jody@sccsi.com
Wed, 8 Jan 1997 05:43:07 -0600


> The cleanest solution to your problem would be to define a new
> data type, "number with special null value", and define all
> the arithmetic operations on it. You could even do that in Python,
> or if speed matters as a C extension. But even with a C extension
> you would not get the full speed of array operations, since your
> arrays would be of "general object" type.

A neat trick for the C code is to use NAN (Not A Number) for the
missing value and set up a signal handler that is invoked when the
NANs are used.  During the signal handler, you then can decide what
result you want to return the to proceedure that invoked the handler.
On many machines, this is much faster than doing the following code:

	if a == MISSING or b == MISSING:
		return MISSING

for every item in the array.

Jody


=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================