[PyQt] Re: Bug ovverriding sizeHint

Giovanni Bajo rasky at develer.com
Mon Feb 25 15:55:26 GMT 2008


On 2/25/2008 4:46 PM, Phil Thompson wrote:

>> Thanks for your change, but this is a showstopper for me, so I guess I
>> will have to find a different solution. Specifically, I would also need
>> to remove the attribute and readd it later, etc.
>> (The GC issue also worries me, but I have not analyzed its implications
>> in details).
>>
>> I'm mentioning because, if you are not comfortable with this change, you
>> might want to simply back it out as I'm not going to excercise it.
> 
> I've already made a note to myself in the comments to consider removing the 
> cache. It avoids a GIL acquire/release and an attribute lookup each time C++ 
> invokes a virtual.
> 
> (I've just noticed that the GIL is acquired and released in the common case 
> where there is no Python reimplementation - now fixed.)
> 
> You can experiment with disabling the cache if you want (just remove the call 
> that sets the flag when the cache has been filled). I'd remove the cache if 
> was proved not to be of significant benefit.

OK I'll try. I'm not a CPython guru, but isn't there a C-level 
__setattr__ (that is, a callback when a certain attribute is changed) 
that you can override for SIP objects with C++ virtual functions? Given 
that the C++ virtual functions is a fixed compile-time list, it 
shouldn't be too slow to invalidate the cache only when required.
-- 
Giovanni Bajo



More information about the PyQt mailing list