Opened 15 years ago

Closed 14 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: no UI/UX: no

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 15 years ago.

Download all attachments as: .zip

Change History (5)

by Martin v. Löwis, 15 years ago

Attachment: key.diff added

comment:1 by Alex Gaynor, 15 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Martin v. Löwis, 15 years ago

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 by Karen Tracey, 15 years ago

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 by Russell Keith-Magee, 14 years ago

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