Page 1 of 1

Defining part of a class in C and the rest in Python in dynamic modules

Posted: Wed Aug 25, 2021 3:54 pm
by nedkonz
I'm trying to implement a single class instance method in C, with the rest of the class's code in Python.
I'm doing this in a dynamic module so I can load the resultant .mpy file at runtime.
So I have a single C file and a single Python file in the same directory.
Can someone give me a quick summary of what I have to do in the code to get this to work?
At module initialization, will I have access to the class I'm writing the method for?
Thanks!

Re: Defining part of a class in C and the rest in Python in dynamic modules

Posted: Wed Aug 25, 2021 5:42 pm
by nedkonz
OK, more info... at C initialization time the class that's defined in the Python file isn't available in the module's dictionary yet. So I guess I'll have to set up the C functions outside the class and call from within the class, unless there's a way to make a bound method (for a Timer callback) at runtime from C.