Custom NamedTuple constructor

hi, I am working with custom NamedTuple classes, and I want to override the constructor. I have been able to successfully override the boxing, unboxing, and typeof by imitating what Numba does for NamedTuples and applying it to my class via the low level extension API (Low-level extension API — Numba 0.55.0.dev0+549.ga25a17e48.dirty-py3.7-linux-x86_64.egg documentation).

In the future I’ll probably migrate to StructRef, but for now this is doing what I need, except that the constructor inside jitted functions is typing the instance as a NamedTuple and not as my custom type.
When I instantiate in interpreted code, it’s ok because I have overridden the type inference for function arguments, but for construction inside jitted function I have not been able to find the Numba internal code that takes care of the typing of the named tuple constructor. I found the lowering in cpython/ but I cannot find the typing.

Does anyone know where that code is?


Hi @luk-f-a,

I think this could be what you are looking for:

Hope this helps?

thanks @stuartarchibald , that led me to numba/ at a25a17e48877f8ae5e31d70cdeff10316c936a8e · numba/numba · GitHub, and those two things are what I was looking for.