In respect with continued development of PyCXX and being nice project I would like to submit following patch that improves PyCXX method's calling speed/performance by almost 2 times (tested in our projects with C/C++ core working with around 2304 python script files). Due to intensive interaction of our cor with Python scripting subsystem it was interesting to find areas for performance improvement in PyCXX method calling routines. As result solution based on hash_map<> hashed container implementation was chosen and small corrections to lookup procedures in Extensions.hxx file were done to avoid double map<> lookups. Custom string hashing module was chosen based on well-known algorythm designed by Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) to benefit from better performance and hash distribution for safety sake.
Although to provide compatibility with compilers having specific hash_map<> implementation and etc special defines provided in Config.hxx, which could also b used to return PyCXX to traditional std::map<> usage, so users have choice.
Following patch is not new and was used in our project for some time and as result had thorough real-life testing.
Tested/worked on platforms: WIN64/WIN32 compiled with MS VS 7.x - 9.0 and ICC, 64-/32-bit Linux compiled with GCC 4.x.
Performance increase was for about 2 times in some cases and resulted in noticable application relaxation of CPU usage.
Log in to post a comment.