[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Smith Martin Martin.Smith at theqtcompany.com
Sun Jul 12 13:11:54 CEST 2015


>To me it looks like you're trying to argue about a very particular use of
>QList. At that level of details, it has no business being in the docs.

And yet you wrote a blog about it instead of submitting the info to us to update the QList documentation. Currently, the QList page says this:

"QList<T>, QLinkedList<T>, and QVector<T> provide similar functionality. Here's an overview:
For most purposes, QList is the right class to use. Its index-based API is more convenient than QLinkedList's iterator-based API, and it is usually faster than QVector because of the way it stores its items in memory. It also expands to less code in your executable."

If your argument is correct, then all three of those sentences are false, yes?

What do you mean here when you say default: "If you want to update the docs, as a first approximation, write that QVector
is _the_ default seqential (and, if it wasn't so awkward to use, also _the_
default associative) container (even though it's not currently reflected in
the Qt API)."

Do you mean: The user should always choose QVector over QList unless he has a specific reason (not listed) to use QList?

>Better provide a benchmark into which users can easily plug their own types
>and that plots relative performance of various containers at various sizes.
>Then they can use that on their platform, on their type, with their access
>patterns to determine which container to choose.

I doubt that benchmark tool would work as well as just writing your application with QList, benchmarking it, and then replacing QList with QVector and benchmarking it again. Apparently, it is quite easy to replace QList with QVector.

martin


________________________________________
From: development-bounces+martin.smith=theqtcompany.com at qt-project.org <development-bounces+martin.smith=theqtcompany.com at qt-project.org> on behalf of Marc Mutz <marc.mutz at kdab.com>
Sent: Sunday, July 12, 2015 1:08 PM
To: development at qt-project.org
Subject: Re: [Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

On Sunday 12 July 2015 10:13:30 Smith Martin wrote:
> m trying to get information for updating the documentation for QList.

To me it looks like you're trying to argue about a very particular use of
QList. At that level of details, it has no business being in the docs.

Better provide a benchmark into which users can easily plug their own types
and that plots relative performance of various containers at various sizes.
Then they can use that on their platform, on their type, with their access
patterns to determine which container to choose.

> At
> the moment, it is misleading, judging by what you are saying. Maintaining
> the documentation isn't a red herring. It's actually my job.

If you want to update the docs, as a first approximation, write that QVector
is _the_ default seqential (and, if it wasn't so awkward to use, also _the_
default associative) container (even though it's not currently reflected in
the Qt API). All other containers (incl. QMap, QSet, ..., but maybe not QHash)
should only be used after very careful profiling and QList should not be used
by mere mortals at all.

That's a good stating point. From there, refinements can be made.

Thanks,
Marc

--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


More information about the Development mailing list