[QGIS-Developer] SIP is insane
Even Rouault
even.rouault at spatialys.com
Fri Jun 5 17:18:55 PDT 2026
Hi,
sorry for the eye-catching email title, couldn't resist.
Am I the only QGIS dev highly frustrated by the bottleneck of sip-build
when building QGIS? Can we do something (funding upstream?) to improve that?
Also some mind bogging stats:
- size of all QGIS headers: find ../src -name "*.h" -exec cat {} \; |
wc -l : 570 288
- size of QGIS .cpp + .ui: find ../src \( -name "*.cpp" -o -name "*.ui"
\) -exec cat {} \; | wc -l : 1 497 216
So QGIS is just a 2 million LoC (excluding tests) code base
- size of .sip generated files: find . -name "*.sip" -exec cat {} \; |
wc -l : 335 425
- size of SIP generated .cpp files: find python/ -name "*.cpp" -exec
cat {} \; | wc -l: 7 532 645 . 7.5 millions LoC !!!
- size of MOC generated .cpp files: find src/ -name "*.cpp" -exec cat {}
\; | wc -l : 2 051 769
So 2 observations:
- we bind to Python a very large part of our header files (more than
half). I've always found that the amount of things exposed to Python was
excessive. IMHO we should be much more conservative, and wait for plugin
authors to ask for an API to be exposed, rather than expose it prematurely.
- SIP generates > 20 times more lines of .cpp than .sip files!!! Or
3.75 times more lines of code than QGIS actual logic.
That shows in (stripped) .so files:
- output/python/qgis/*.so : 130 MB
- output/lib/*.so.4.1.0 : 170 MB.
So not as crazy as the 7.5 vs 2 MLOC of ratio, but still.
Comparison with GDAL and SWIG:
- size of public .h headers: 50 162 .
- size of Python SWIG source .i files: ~43 000 (hard to count exactly
as there's some bits of Java and C# in this count)
- size of SWIG Python generated .cpp files: 164 151 .
So a 4x only ratio of .cpp vs .i
I don't recommend SWIG, but something looks fishy in the kingdom of SIP
Even
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the QGIS-Developer
mailing list