Hybrid C module + Python module (namespaces) #16649
-
I there a way to write part of a custom module in C and then append Python defined functions to it during the build process using something in the form of frozen bytecode? Example: Suppose you have two files:
The result I'm trying to achieve is something like: >>> import modtest
>>> modtest.helloFromC()
>>> modtest.helloFromPython() Essentially allowing to bundle modules under one 'namespace' |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Can't you just create module _modtest with the c code in it, and then have modtest.py be
This is how many of the main python library modules are handled, with low-level modules prefixed with '_'. |
Beta Was this translation helpful? Give feedback.
-
Having two files is exactly that gets merged is exactly how the dynamic native modules build setup work. See for example, https://github.com/emlearn/emlearn-micropython/tree/master/src/emlearn_fft |
Beta Was this translation helpful? Give feedback.
Can't you just create module _modtest with the c code in it, and then have modtest.py be
This is how many of the main python library modules are handled, with low-level modules prefixed with '_'.