[Numpy-discussion] ANN: MaskedArray as a subclass of ndarray?-?followup

Robert Kern robert.kern at gmail.com
Fri Jan 19 14:00:44 EST 2007


Stefan van der Walt wrote:

> A "nice C level api" sounds like the definition of oxymoron :) Why
> would we argue for more C than absolutely necessary in a Python-based
> library?

Well, it's more often absolutely necessary than you might think. Any common
operation on the array should be written in C to avoid the Python function call
overhead. We learned that with recarrays. The a.column_name notation (equivalent
to a['column_name']) in implemented in a Python method __getattribute__. If you
happen to use this in a tight loop, you'll find that __getattribute__ is a
bottleneck.

Unfortunately, the methods you might want to add or override on an ndarray
subclass are going to be the ones that you would want to be efficient.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco



More information about the NumPy-Discussion mailing list