From: Marco D. <mar...@gm...> - 2009-06-23 09:50:19
|
Hi, I'd like to understand more about the optimizations that SWIG performs when generating Python wrappers. I'm evaluating several technologies to wrap a C++ API and surprisingly when I generate the wrapper using SWIG and the -O flag the Python wrapper performs faster than the wrapper I've developed using the Python C API. I'm no guru of the Python C API but that was surprising. I'm particularly interested to understand -fastdispatch, -fastproxy and -dirvtable as I guess that's where the speedup comes since the wrapped classes have several virtual functions. So can somebody give me a brief overview of how these optimization works before I look deeper in the code ? Thanks, Marco |
From: William S F. <ws...@fu...> - 2009-06-23 21:27:43
|
Marco Dinacci wrote: > Hi, > > I'd like to understand more about the optimizations that SWIG performs > when generating Python wrappers. > I'm evaluating several technologies to wrap a C++ API and surprisingly > when I generate the wrapper using SWIG and the -O flag the Python > wrapper performs faster than the wrapper I've developed using the > Python C API. I'm no guru of the Python C API but that was surprising. > I'm particularly interested to understand -fastdispatch, -fastproxy > and -dirvtable as I guess that's where the speedup comes since the > wrapped classes have several virtual functions. > So can somebody give me a brief overview of how these optimization > works before I look deeper in the code ? > Marco, The optimization work was largely done by one of the developers who didn't document that much and is no longer around. You should, however, find some key information in the CHANGES file. Failing that the source and commit history in the python files will be the next place to look. William |