You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typing necessary for static Python-Numpy compilers like Pythran and Cython #59
Static Python-Numpy compilers like Pythran and Cython (and others) need type information.
For Transonic (a tools to use Python-Numpy compilers, see https://transonic.readthedocs.io), I had to implement a simple system to be able to give enough information in Python about the types supported by functions.
I give here an example of what is possible (more complex things are sometimes needed but this is the minimum, fused data-types and "fused" number of dimensions of the array):
Is it at least possible to express that an argument is an array of a particular dtype and a particular dimension?
This is possible in NumPy for dtypes already, and we're working hard on implementing "rank-typing", i.e. statically describing the no. of dimensions. It might sound easy, but in reality it's one of the most difficult things I've ever worked on in my career.
And if it's possible to do in NumPy, then it should also be possible to do in general. But getting there is be no means easy.
Activity
jorenham commentedon Oct 2, 2025
This won't be possible to express in a way that's compatible with the Python typing spec, I'm afraid.
paugier commentedon Oct 3, 2025
Is it at least possible to express that an argument is an array of a particular dtype and a particular dimension?
jorenham commentedon Oct 3, 2025
This is possible in NumPy for dtypes already, and we're working hard on implementing "rank-typing", i.e. statically describing the no. of dimensions. It might sound easy, but in reality it's one of the most difficult things I've ever worked on in my career.
And if it's possible to do in NumPy, then it should also be possible to do in general. But getting there is be no means easy.
lucascolley commentedon Oct 3, 2025
x-ref numpy/numtype#539