2 ms·
In C, you need header files so that vars are declared before they're used. How does cython deal with this? I find headers painful, and would appreciate a memor
by cturner 12y ago
In C, you need header files so that vars are declared before they're used. How does cython deal with this? I find headers painful, and would appreciate a memory foundry language more if it didn't suffer this.
- andreasvc 12y agoIn Cython you can use Python modules/functions/variables as you normally would, dynamically and without declaring them. To integrate with C code you do need headers and type declarations. Other tools (ctypes, cffi) can load libraries dynamically, but I think that has its own tradeoffs.
- syllogism 12y agoUnfortunately, you're dead right --- this sucks in C and it sucks in Cython! I don't understand why .pxd files are necessary --- they should be generateable from the .pyx files. At some point I'll have a go at this... But, as of now, you need to maintain this separate file, which you must keep synchronised to changes in the original. And, yes --- this sucks! The only mercy is that writing code in the headers is illegal.
- andreasvc 12y agoIt is not illegal to write code in pxd files. For cdef functions to be inline-able across modules, they need to be specified in a pxd file. But that is the exception to the rule.