This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients tim.peters
Date 2021-10-19.22:08:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634681337.62.0.706016282775.issue45530@roundup.psfhosted.org>
In-reply-to
Content
The attached tupsort.py gives a simple. focused example. Typical output on my box:

float       3.10
(float,)   11.75
[float]    25.68

It's sorting a large list of floats. In the first line the list contains plain floats. In the second line, each float was wrapped in a 1-tuple. In the last line, wrapped in a singleton list.

Essentially any overhead of any kind is more expensive than merely comparing two floats in HW, so overhead is approximately everything here.  The tuple and list comparison functions are very similar, and the large advantage of "(float,)" over "[float]" is mostly due to that unsafe_tuple_compare() uses one less PyObject_RichCompareBool() call to resolve each compare (assuming that all floats in the list are distinct, which I didn't check, but is almost certainly the case).

Getting rid of its other PyObject_RichCompareBool() should yield another nice speed boost.

The pattern is worth addressing because tuples are routinely used as key= arguments to achieve multi-key sorting.
History
Date User Action Args
2021-10-19 22:08:57tim.peterssetrecipients: + tim.peters
2021-10-19 22:08:57tim.peterssetmessageid: <1634681337.62.0.706016282775.issue45530@roundup.psfhosted.org>
2021-10-19 22:08:57tim.peterslinkissue45530 messages
2021-10-19 22:08:57tim.peterscreate