bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#69709: `sort` interface improvement and universal ordering predicate


From: Mattias Engdegård
Subject: bug#69709: `sort` interface improvement and universal ordering predicate
Date: Thu, 21 Mar 2024 15:55:43 +0100

20 mars 2024 kl. 20.37 skrev Stefan Monnier <monnier@iro.umontreal.ca>:

> IOW, I vote for `<`!

That may actually be within the realms of possibility. Some snags:

* Not sure if code using `<` and expect a type error for non-numbers would be 
confused (probably not)
* Making `value<` n-ary would slow it down a bit, unclear how much
* `value<` compares markers by buffer then position, `<` by position only
* `<` can compare markers with numbers
* We expect consistency and shared code for all of < > <= >= = /= but it's 
unclear how `value<` would be generalised in that direction (at least if we 
care about NaN correctness)

Currently, `value<` treats NaN as if it were equal to any number, which is 
terrible and useless but consistent with `<`. Other options would include order 
NaN distinct from any number, perhaps just consider all NaNs to be equal and 
put them before or after all numbers.

`value<` is actually quite a bit faster than `<` which has a terribly 
cumbersome implementation, except for pairs of fixnums which apparently got 
special-cased in `<` and the other inequalities fairly recently.

By the way, I ran some more benchmarks: it turns out that `car-less-than-car`, 
the secret shortcut that you just had to know, now gives roughly the same speed 
as :key #'car which is a lot more discoverable (and works for many other types).








reply via email to

[Prev in Thread] Current Thread [Next in Thread]