[QGIS-Developer] SIP is insane
David Koňařík
dvdkon at konarici.cz
Sat Jun 6 02:54:38 PDT 2026
Hi,
as you might remember, I did some work on improving SIP compilation
times last year. I managed to improve performance, but sadly not fully
refactor SIP to allow for a per-class or per-header build. I'll try to
dig out some of my notes and memories on why it was hard if you want.
That said, I only looked at improving performance of sip-build, maybe
there is some low-hanging fruit in the generated .cpp files.
SIP is developed pretty much solely by Phil Thompson, he has a company
called Riverbank Computing. No idea how interested he'd be in being
contracted for a large refactor, though.
David Koňařík
On Sat, 2026-06-06 at 02:18 +0200, Even Rouault via QGIS-Developer
wrote:
> 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
More information about the QGIS-Developer
mailing list