Message242237
I think the documentation is fine:
"""
The key corresponding to each item in the list is calculated once and then used for the entire sorting process.
"""
This corresponds with the standard "decorate-sort-undecorate" approach to handling key functions in sorts. It's a common computer science technique, possibly not as familiar to a mathematician, but regardless, the docs clearly state that the key is calculated for each item.
Your existing code, with a check for Omega having length 1 and omitting the sort in that case, looks entirely reasonable to me. Maybe you could add a comment "Avoid a costly calculation of the key when length is 1, as we know we don't need to sort then" and leave it at that. |
|
Date |
User |
Action |
Args |
2015-04-29 17:44:22 | paul.moore | set | recipients:
+ paul.moore, tim.peters, rhettinger, mark.dickinson, benjamin.peterson, r.david.murray, matrixise, Sergey.Kirpichev |
2015-04-29 17:44:22 | paul.moore | set | messageid: <1430329462.57.0.730793521635.issue24075@psf.upfronthosting.co.za> |
2015-04-29 17:44:22 | paul.moore | link | issue24075 messages |
2015-04-29 17:44:22 | paul.moore | create | |
|