[Python-ideas] (no subject)
solipsis at pitrou.net
Mon Dec 4 11:30:42 EST 2017
On Tue, 5 Dec 2017 02:52:44 +1100
Steven D'Aprano <steve at pearwood.info> wrote:
> On Mon, Dec 04, 2017 at 01:52:19PM +0100, Antoine Pitrou wrote:
> > On Mon, 4 Dec 2017 23:16:11 +1100
> > Steven D'Aprano <steve at pearwood.info> wrote:
> > > On Mon, Dec 04, 2017 at 12:06:38PM +0100, Antoine Pitrou wrote:
> > >
> > > > There are definitely advantages. Sorting calls __lt__ for each
> > > > comparison (that is, O(n log n) times) while __key__ would only be
> > > > called once per item at the start (that is, O(n) times).
> > >
> > > Passing a key function doesn't magically turn a O(n log n) comparison
> > > sort into a O(n) sort.
> > Where did I say it did?
> See the text from you quoted above. You said there are "definitely
> [performance] advantages" by using a key function. You then compare:
> - calling __lt__ O(n log n) times, versus
> - calling the key function O(n) times.
> This is a classic "apples versus oranges" comparison. You compare
> *actually sorting the list* with *not sorting the list* and conclude
> that they key function provides a performance advantage.
At this point, I can only assume you are trolling by twisting my
words... even though you later quote the part which explicitly
clarifies that I was *not* saying what you claim I did.
Why you seem to think that is contributing anything to the discussion
rather than derailing it is beyond me. In any case, don't expect
further responses from me.
More information about the Python-ideas