[PyQt] Re: Bug ovverriding sizeHint
Phil Thompson
phil at riverbankcomputing.co.uk
Mon Feb 25 16:06:26 GMT 2008
On Monday 25 February 2008, Giovanni Bajo wrote:
> 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.
Yes, but the cache is checked before getattr() is called. The cache is
specifically for Python reimplementations, not for general attribute lookup.
It would be possible to add a function to the sip module to invalidate the
cache for a particular object, but that would also break compatibility.
Phil
More information about the PyQt
mailing list