3 ms·
How hard it is to port a C extension? I don't really know the APIs, but is it impossible to transform by a script?
by gkya 10y ago
How hard it is to port a C extension? I don't really know the APIs, but is it impossible to transform by a script?
- novocaine 10y agoMy experience is that it is drastically easier to port C extensions than to port python code itself - the C API hasn't really changed a lot and it's usually very easy to reason about C code due to it being more strongly typed than python. The only reason why it might be hard is you are unfamiliar with the extension's code and/or C
- throwawayish 10y agoNot hard. You can support 3 and 2 in the same file without much hassle. Practical example: https://github.com/zopefoundation/BTrees/blob/master/BTrees/_compat.h https://github.com/zopefoundation/BTrees/blob/master/BTrees/... https://github.com/zopefoundation/BTrees/blob/master/BTrees/BTreeModuleTemplate.c https://github.com/zopefoundation/BTrees/blob/master/BTrees/... There are a couple #if PY3K, but not much, really. I ported a bunch of extension modules, total a couple thousand LOC, and it was pretty much a matter of reading the docs (see guide at https://docs.python.org/3/howto/cporting.html https://docs.python.org/3/howto/cporting.html ) and adding a few #ifs. Total time maybe an hour or two.
- deleted 10y ago[deleted]