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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to