Ticket #759 (new enhancement)
Runtime Compilation of a module [patch]
|Reported by:||bfredl||Owned by:||somebody|
|Component:||Build System||Keywords:||inline, module|
It would be useful if there was a function that took a string of cython code, compiled it as a .pyx file, and then returned a live cython module. Now, cython.inline sort of does this, but it also preprocesses the code under the assumption that it is a function-level chunk, and then excutes this chunck, automagically fetching unbound variables from the invoking envirionment.
While this is very handy in many applications, I would also find it useful at runtime compile many defs/cdefs/cpdefs at the same time, and manually control passing in/out data. The main use case would be using cython as a backend for dynamic code generation.
First I tried to improve cython.inline to make this easier, but it felt like constructing a better screwdriver in order to hammer in a nail. Instead I wrote cython.compile_module (mostly reusing cython.inline) which just compiles a string as if it was a .pyx file, returning the module object. Patch attached.