I am trying to use numba classes in conjunction with
functools.singledispatch (which would seem a useful way to get around lack of inheritance and unlowerable functions):
@nbx.jitclass(spec) class Foo: ... @nbx.jitclass(spec) class Bar: ... @singledispatch def act(inst: object): ... @act.register def act_foo(inst: Foo): ... @act.register def act_bar(inst: Bar): ...
Unfortunately, when I call with a
Bar instance, the derived functions are not invoked. A look at the types of instance vs the registered type in the singledispatch registry shows why: the class in registry is
<class 'numba.experimental.jitclass.base.Foo> while the instance has type:
<class 'numba.experimental.jitclass.boxing.Foo>. Can I somehow get a “boxing” class object from the “base” class object, so I can register it appropriately?
(A more robust solution/feature would be to use ABC to register instances of “boxing” as instances of “base”.)