[Python-Dev] Python3 regret about deleting list.sort(cmp=...)
"Martin v. Löwis"
martin at v.loewis.de
Sun Mar 13 00:41:23 CET 2011
More information about the Python-Dev mailing list
Sun Mar 13 00:41:23 CET 2011
- Previous message: [Python-Dev] Python3 regret about deleting list.sort(cmp=...)
- Next message: [Python-Dev] Python3 regret about deleting list.sort(cmp=...)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Am 12.03.11 18:00, schrieb Glenn Linderman: > On 3/12/2011 1:55 PM, Fredrik Johansson wrote: >> Consider sorting a list of pairs representing fractions. This can be >> done easily in Python 2.x with the comparison function lambda >> (p,q),(r,s): cmp(p*s, q*r). In Python 2.6, this is about 40 times >> faster than using fractions.Fraction as a key function. > > Am I correct in concluding that various ideas to eliminate or limit the > size of the key= cache would not help this use case at all? That's correct. However, there is a straight-forward day of getting the same comparison algorithm with the cmp_to_key class in 3.x. Fredrik classified this as "ugly and slow"; I'm not sure where this classification comes from. Regards, Martin
- Previous message: [Python-Dev] Python3 regret about deleting list.sort(cmp=...)
- Next message: [Python-Dev] Python3 regret about deleting list.sort(cmp=...)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list