[PySide] model/view: faster to access a user role than accessing a dict?

Tim Roberts timr at probo.com
Mon Oct 3 18:34:05 CEST 2022


Frank Rueter wrote:
>
> I am building a model for a tree view and have a dictionary that 
> represents all the data in the required hierarchy.
> I have to be able to filter the view, select things programmatically 
> and show info based on selected items etc.
> I am wondering:
> With all required data per item available in a dict, is it more 
> efficient to just stuff that into the item's UserRole data or to 
> create custom user roles for each value in the dict that I will be 
> filtering/sorting by or looking up for some other reason?
> E.g.:
> Will there be a difference in performance with this:

Let's be honest.  This is code that gets execute once. Performance is 
not a consideration.  Do whatever makes the code simpler.

It's almost never smart to spend time optimizing your initialization.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3428 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20221003/b02b9f28/attachment.bin>


More information about the PySide mailing list