[Numpy-discussion] On my Cython/NumPy project

Dag Sverre Seljebotn dagss@student.matnat.uio...
Sat Jun 21 17:44:36 CDT 2008

Matthew Brett wrote:
> Hi,
>> Well... the Cython compiler definitely needs to know about which type it
>> is -- the array simply has a byte buffer, and one needs to know how to
>> interpret that (how many bytes per element etc.).
> It may be not practical, and, as I say, I haven't thought deeply
> enough about this to offer this as anything but a silly question, but
> would it not be possible to output C code switch statements that would
> deal with (some of) the possible types np.array could contain?

In the way you imagine it I don't think it would be a good solution. It is
possible that Cython might grow some support for type-generalized
programming a la C++ templates (though in a more Pythonic fashion); and in
that case, you could use those for ndarray types as well.

The feature of compiling code for multiple types is somewhat orthogonal to
ndarray support; better treat them seperately and take one at the time.
There's lots of non-NumPy code that would benefit for such a feature as

Dag Sverre

More information about the Numpy-discussion mailing list