Opened 7 years ago

Closed 6 years ago

#12746 closed (fixed)

Use key argument in sort calls

Reported by: Martin v. Löwis Owned by: nobody
Component: Uncategorized Version: 1.2-alpha
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Now that Python 2.4 is the minimum supported version, it is possible to replace all comparison functions with key functions. The attached patch does that.

Doing so has two advantages:

  • it may be slightly faster, in particular, if the comparing the key values is faster than calling the cmp function
  • it helps moving Django towards Python 3, which doesn't support the compare function anymore.

With the patch, I don't get any additional failures when testing on trunk.

Attachments (1)

key.diff (5.5 KB) - added by Martin v. Löwis 7 years ago.

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by Martin v. Löwis

Attachment: key.diff added

comment:1 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedReady for checkin

comment:2 Changed 7 years ago by Martin v. Löwis

As this is my first Django contribution, I'm not sure what is supposed to happen next. Notice that I don't have commit privileges, so I couldn't check that in myself.

comment:3 Changed 7 years ago by Karen Tracey

http://docs.djangoproject.com/en/dev/internals/contributing/#ticket-triage has a picture and some description of Django's process. You weren't expected to check it in yourself, Alex setting it ready for checkin is just a way to signal he has reviewed it and thinks it's ready.

comment:4 Changed 6 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [13509]) Fixed #12746 -- Updated sorting calls to use 'key' instead of 'cmp'. This will be slightly faster in certain circumstances, but more importantly, is a required step for migration to Python 3. Thanks to Martin van Loewis for the patch.

Note: See TracTickets for help on using tickets.
Back to Top