[PyQt] SIP newcomer questions/complaints
Giovanni Bajo
rasky at develer.com
Mon Apr 7 14:38:10 BST 2008
On 4/7/2008 2:11 AM, Kevin Watters wrote:
> 3) I ended up using the distutils support--which worked great out of the box.
> But now my scripts are generating enough time to make the compile-link time
> cycle significant. My SIP files use one root file that %Includes all of the
> other SIP files so that everything goes into one module.
>
> But when I change one of the sub SIP files, SIP doesn't recognize that its
> corresponding files need to be regenerated. So the only way I've found to
> recompile is to "touch" the root SIP file, which causes SIP to regen ALL of my
> generated cpp files, and subsequent GCC to recompile ALL of them. Is there an
> easy solution to this?
If you look at PyQt3Support (http://www.develer.com/oss/PyQt3Support),
in the patch:
http://www.develer.com/~naufraghi/PyQt3Support/PyQt3Support_PyQt4.3.3_GPL_r2.patch
you will find a cache implementation for PyQt4's configure.py (search
for "manage_cache").
Basically, configure.py is changed so that the output of SIP goes to a
temporary directory; then, only the files that changed since last time
are actually copied over the compilation directory, so that gcc will
compile only those ones.
You might grab that code and integrate it within your setup.py.
> 6) The docs show show no comparisons with similar tools. I'm trying SIP to see
> if the memory usage of a large wxPython app can be reduced--I have seen
> comparisons claiming that SIP would be slower than hand generated code, but
> faster than SWIG. This seems to be a fair assumption, since SWIG generates lots
> of Python shadow classes, and SIP does not. But some data, or even anecdotal
> advice about what you're going to get out of SIP compared to SWIG might be
> useful in the documentation.
Such statistics are hard to find because usually developers do not write
bindings twice :)
There are good reasons for using SIP over SWIG, IMO:
1) Bindings for classes and methods are generated *lazily* on first
usage. This means that the initial import is very fast and does not
consume much memory; and when the program starts, only the (small)
subset of the wxWidget functions actually used by the program contribute
to memory occupation.
2) SIP is very Python centric, and has many useful features and
shortcuts for binding C++ code into Python. All the /Transfer/ and
friends stuff, for instance, is very powerful and elegant (once you get
to understand it fully :).
Since I switched to SIP from SWIG, I haven't looked back.
BTW, I don't know wxWidgets, but if it uses much STL stuff, let me know
because I have an unreleased "SIP STL meta-binding", which is basically
a program which is able to *generate* SIP code for the exact STL subset
(= template specializations) used by the library you're writing bindings
for; SIP's support for C++ templates is quite weak, so wrapping
something like of STL requires abuse of copy & paste, which is automated
by this tool.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com
More information about the PyQt
mailing list