[PyQt] Clarifications on new versions of SIP/PyQt

Phil Thompson phil at riverbankcomputing.com
Mon Jan 18 11:48:05 GMT 2010


On Mon, 18 Jan 2010 12:36:31 +0100, Giovanni Bajo <rasky at develer.com>
wrote:
> Il giorno lun, 18/01/2010 alle 11.33 +0000, Phil Thompson ha scritto:
>> On Mon, 18 Jan 2010 12:11:20 +0100, Giovanni Bajo <rasky at develer.com>
>> wrote:
>> > Hi Phil,
>> > 
>> > I read in the SIP 4.10 changelog:
>> > 
>> > Added the -P command line option to build modules with "protected"
>> > redefined to "public" if supported by the platform. This can result in
>> > significantly smaller modules.
>> > 
>> > Can you please elaborate on:
>> > 
>> >  * What consequences on user's code the -P flag has. Does it break
>> > source code compatibility? What exactly is allowed when the -P flag is
>> > specified, and forbidden otherwise?
>> >  * Why does it affect code size so much?
>> > 
>> > Also, in PyQt changelog:
>> > 
>> > Significantly reduced the size of the modules on Linux and MacOS/X.
>> > 
>> > Is this related to the -P flag above? If so, does it mean that it is
>> > active by default when compiling PyQt on Linux/Mac? If not, how was
the
>> > result achieved? Why it does not apply to Windows as well?
>> 
>> Yes it's the same thing.
>> 
>> Using the preprocessor to redefine "protected" as "public" is a common
>> hack
>> that allows C++ code to call protected methods from outside of a
>> sub-class.
>> It can only work if the name mangling scheme doesn't embed the access in
>> the name of the method. In other words, the actual name in the shared
>> library of the public void foo() is identical to the protected void
>> foo().
>> On Linux and MacOS this is the case - but it isn't on Windows.
>> 
>> SIP has to be able to call protected methods from outside of a
sub-class.
>> It does this my generating extra code in the form of a sub-class and
>> wrapper methods. By exploiting the hack SIP doesn't need to generate
that
>> extra code - which can be a significant saving.
>> 
>> All this should be completely transparent to PyQt code.
> 
> Thanks for the clarification.
> 
> I now understand that -P can be used on any SIP-wrapped module without
> ever affecting its Python user code. This is great news of course :)
> 
> Do you plan to ever turn -P on by default?

Unlikely because of the platform differences.

PyQt will use it if it can.

Phil


More information about the PyQt mailing list