[PyQt] SIP newcomer questions/complaints

Phil Thompson phil at riverbankcomputing.com
Mon Apr 7 01:43:04 BST 2008


On Monday 07 April 2008, Kevin Watters wrote:
> I just started looking into SIP this weekend (I'm trying to wrap the
> wxWidgets library--has this been attempted before?),

I'd be very surprised!

> and I had a couple 
> thoughts and questions.
>
> 1) The docs make no mention of the fact that you cannot use keyword
> arguments when calling C functions. This was a surprising limitation coming
> from SWIG.
>
> 2) The docs for creating and using a Makefile are lacking--I'm not sure how
> to get them to work. Do I need a ParentMakefile above the one in my source
> directory? Is my source directory the same as my generated source
> directory? Admittedly I'm completely in the dark when it comes to make, so
> I got stuck at
>
> make[1]: *** No rule to make target `sipAPIwx.h', needed by
> `sipwxcmodule.o'. Stop.
>
> This is probably no big deal for most people fluent in with UNIX dev
> toolchain, but a simple example with a multi SIP file project might help
> the rest of us with this :-)

Look at the PyQt sources for a large example, and the QScintilla sources for 
something simpler.

> 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?

No.

> 4) Since there is no preprocessor support for .sip files, I ended up using
> %Feature and %If to enable and disable blocks of code, depending on the
> configuration. But it's annoying to have to pass -x FEATURENAME on the
> commandline to disable features. Obviously this can be automated, but it
> might be better to allow "%Feature On" or "%Feature Off," or to have an
> option for SIP to take additional arguments from a file.
>
> 5) The grammar for SIP syntax mentions __repr__, but the docs do not. After
> some strange compile errors I managed to get a __repr__ to work with the
> following code:
>
>  void __repr__(); %MethodCode return PyString_FromFormat("<wx.Size (%d,
> %d)>", sipCpp->x, sipCpp->y); %End
>
> Why does the type have to be void?

It shouldn't be, but you are getting away with it because you are explicitly 
returning rather than setting the sipRes variable. See the PyQt sources.

> 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.
>
> Thanks in advance for any help!
>
> - Kevin

Phil


More information about the PyQt mailing list