[PyKDE] QString in PyQt4 - Request for Comments

Giovanni Bajo rasky at develer.com
Tue Oct 18 21:42:42 BST 2005


Simon Edwards <simon at simonzone.com> wrote:

>> Would it mean that QString content would always be copied when used in
>> Python ? If yes, copying a QString from a widget to another (for example
>> widget1.setCaption( widget2.caption() ) ) would lead to an unnecessary
>> copy.
>
> True, but how often do you copy a string from one widget to another? I'm
> guessing almost never (never= not often enough to worry about, or be
> performance critical).

I'm not saying it happens often. I'm saying that we the proposed change it
would be *impossible* to do it. On the other hand, with the current
interface it is possible to do exactly what you want, it is just a little
less convenient for the common case.

> The whole "add str()" thing is a pain
> in the ass and leads to subtle bugs (espically when you use strings as
keys
> in dictionaries).


This is an orthogonal issue, and I admit that it can get annoying pretty
fast. There is a simple solution though: I have been meaning to suggest Phil
to add an exception-raising __hash__ method to QString. Those who want to
hash by identify can still do it explicitally (calling id()), instead of
relying on it being the default.
-- 
Giovanni Bajo




More information about the PyQt mailing list