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

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
nedkonz
Posts: 24
Joined: Thu Aug 05, 2021 9:58 pm

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

Post by nedkonz » Wed Aug 25, 2021 3:54 pm

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!

nedkonz
Posts: 24
Joined: Thu Aug 05, 2021 9:58 pm

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

Post by nedkonz » Wed Aug 25, 2021 5:42 pm

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.

Post Reply