[Erp5-dev] [Erp5-report] r26242 - in /erp5/trunk/products/ERP5: Tool/ tests/

Yoshinori Okuji yo at nexedi.com
Thu Apr 2 17:00:40 CEST 2009


On Thursday 02 April 2009 23:34:33 Julien Muchembled wrote:
> Yoshinori Okuji a écrit :
> > I don't understand why you need to *deprecate* cmp.
>
> I explained in the commit message that using 'cmp' parameter in sorting
> methods (list.sort & sorted) is slow and deprecated. This is a fact.

Slowness does not mean any deprecation.

> More precisely:
>
> * In almost all cases, 'cmp' is _much_ slower that 'key'. In the rare cases
> where using 'cmp' could be faster, it is possible to write a 'key' func
> that behaves like a 'cmp': cf http://code.activestate.com/recipes/576653/
> (Convert a cmp function to a key function).

I don't care about whether it is fast or slow. The fact is that it is quite 
difficult to write a key function in some cases. Note that the complexity of 
the workaround given there is equal to using cmp. So it is an "aim" for 
dealing with Python 3's bad decision, but not for the performance.

> * 'cmp' parameter doesn't exist in Python 3 (and I suppose it will also
> disappear in a future 2.x version). I know this is really far future but it
> appears we already need to convert existing code due to performance issues.
>
> Knowing all this, it is not serious to keep using 'cmp' in new code.

Not at all. You can recommend using key whenever feasible, but you should not 
force to use key only.

Regards,
YO
-- 
Yoshinori Okuji, Nexedi KK President
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.co.jp/
ERP5: Full Featured High End Open Source ERP
http://www.erp5.com/
ERP5 Wiki: Developer Zone for ERP5 Community
http://www.erp5.org/



More information about the Erp5-dev mailing list