One thing I like about numarray's "native" C API is that for
functions that return arrays, the return type is PyArrayObject *, as
opposed to the Numeric-compatible API, where the return types are
PyObject *.
Returning PyObject * in this case basically means you're *always*
doing a cast like this:
PyObject *o;
PyArrayObject *a;
a = (PyArrayObject *)PyArray_ContiguousFromObject(o, PyArray_DOUBLE,
2, 2);
Could we change the API so that PyArrayObject * is used as the return
type?
On a similar note: the 'data' member of PyArrayObject's is a char *,
where it really should be a void *. Being a void pointer would have
the advantage of not needing the cast in cases like this:
double *adata = (double)(a->data);
It would also mean that accidentally dereferencing the pointer would
be a compiler error: currently, a->data[0] is valid, but if a->data
was a void *, it wouldn't be.
Both of these changes wouldn't require recompiling extensions (since
we're just relabelling what the pointer types are), and would be
source-compatible with old code (since the casts used would now be
superfluous). Newer code will also be easier to write.
I'll work on the changes in a svn branch if people think this is a
good idea.
--
|>|\/|<
/------------------------------------------------------------------\
|David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/|cookedm at physics.mcmaster.ca