mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Switches on the sip "-g" switch, which forces sip to release the Python Global Interpreter Lock before calling a qgis c++ method, and reacquire it after. While this flag is not a default sip flag, it is used when building the PyQt API, so can't forsee any issues from enabling it. The benefit however is extreme for PyQGIS based scripts which rely on threads, potentially resulting in massive performance boosts. Without this switch, calling an expensive c++ method (say, building a QgsSpatialIndex using a QgsFeatureIterator) would lock the Python GIL for the duration of the c++ call... which could potentially take minutes or more. With the switch, the lock is released before all calls, so other Python threads are free to merrily grab the lock and do other processing while the original thread chugs away in c++ land. Benchtests of worst-case scenarios (single thread calling thousands of very inexpensive PyQGIS methods (simple getters)) regressed from mean of 154 seconds to 158 with this flag. But that's worst case (and as Intel have recently demonstrated... we can't take yesterday's computing speed as the benchmark for todays ;). Given that best case scenarious (multi-threaded operations calling slow c++ methods) will benefit so greatly from this change, I think it's an acceptable trade off. *This is a step toward potentially re-enabling background execution of python based Processing algorithms, and also should greatly improve QGIS responsiveness when using python based renderers/symbols.