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 paul.moore
Recipients Sergey.Kirpichev, benjamin.peterson, mark.dickinson, matrixise, paul.moore, r.david.murray, rhettinger, tim.peters
Date 2015-04-29.17:44:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1430329462.57.0.730793521635.issue24075@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-04-29 17:44:22paul.mooresetrecipients: + paul.moore, tim.peters, rhettinger, mark.dickinson, benjamin.peterson, r.david.murray, matrixise, Sergey.Kirpichev
2015-04-29 17:44:22paul.mooresetmessageid: <1430329462.57.0.730793521635.issue24075@psf.upfronthosting.co.za>
2015-04-29 17:44:22paul.moorelinkissue24075 messages
2015-04-29 17:44:22paul.moorecreate