On Sun, Nov 22, 2009 at 2:56 AM, n00m <n...@narod.ru> wrote: > I was expecting the 1st method would be *slower* than the 2nd one :-) > Or at least equal... Just random ("intuitive") expectations
The second method repeatedly looks up left_item.__class__.__cmp__ (i.e. Vector.__cmp__) when doing the necessary comparisons between the list items; while these lookups are optimized and are fast, they are not free and cannot be skipped because Python doesn't know the list contains only Vectors. The first method uses the single provided comparison function and thus does no such lookups; hence, it's faster. That's my guess anyway. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list