3 ms·
5. Any type of bit twiddling sucks. Take the time to do it in C and make the extension. I recently had to do something like this and ended up using SWIG to gen
by bbb 17y ago
5. Any type of bit twiddling sucks. Take the time to do it in C and make the extension.
I recently had to do something like this and ended up using SWIG to generate the glue code. However, I noticed that my code had to spent considerable time (many iterations) in the C++ library to reduce overall execution time (but then it did by a factor of 20x-40x).
Do you happen to have some advice on how much speedup could be gained by replacing SWIG with handwritten wrappers?
- sophacles 17y agoMy personal preferences are: Boost.python for C++[1], and Pyrex/Cython for C wrappers. Both make things pretty nice. I never really got into swig, so I'm not sure if there is noticable speedup betwen any of these. As for handwritten wrappers, I have not had any personal experience trying to eke the extra speed from not using a code generator type wrapper. hth
- dagw 17y agoSwig solves a somewhat different problem than Boost.python/pyrex. Swig works better when you have an existing C++ codebase you want to call from python while making as few changes to the C++ side as possible, while Pyrex/Boost work better when you are writing a C or C++ module from scratch to be called from python.