xnd_structinfoand remove that sizes workaround I had. I wasn't able to switch the structs to be opaque pointers in Numba, because I actually have to be able to allocate empty
ndt_context_tto pass into
tp_allocfunction on the
[Pearu Peterson] @saul, I believe that for creating Ndt pyobject we can use
xnd_structinfo approach by implementing
ndtype_alloc in LLVM IR. That was my initial thought and would involve getting pointer to
Ndt_Type value, adding
PyTypeObject struct wrapper to
xnd_structinfo and implementing setter methods within
xnd_structinfo. All these steps are doable.
However, we can implement the creation of a Ndt pyobject witin a C function and then expose this function to LLVM IR. It can be done either within
_ndtypes.c by defining the function as
extern (easy approach in short run), or (in order to keep ndtypes clean from numba related stuff) creating a dummy-python extension module that implements the required
extern function (it would be just harder to get a reference to
Ndt_Type). In either case the
extern function is made available to LLVM IR by importing the python module and binding it as shared library to LLVM as we currently do.
If the approach works, we might need the dummy-python extension module also for other tasks that are easier to do in C (have direct access to struct members) than in LLVM IR (when pointer passing is not sufficient). Such functions can be added to
xnd_structinfo, for instance, in order to keep the number of extension modules minimal.
[Saul Shanabrook] I have enough lower level primitives built up now in the numba support to jit compile a matrix multiply function: https://github.com/Quansight/numba-xnd/blob/8cdd89362aedde4516afedc44b21c5fe7aa9bf3c/tests/test_examples.py
As you can see, it's very low level, similar to how you would write it in C, but in Python. Now I can start building the higher level APIs on top of that that have some more compile time typing knowledge.
extern "C"for the C++ functions, all is well.
thrust::complex(also C++ obviously) by writing C wrapper macros.