[Erp5-report] r23772 - in /erp5/trunk/products: ERP5/Document/ ERP5/Tool/ ERP5Type/ ERP5Typ...

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Sep 23 21:28:46 CEST 2008


Author: kazuhiko
Date: Tue Sep 23 21:28:42 2008
New Revision: 23772

URL: http://svn.erp5.org?rev=23772&view=rev
Log:
use sort(key=) instead of sort(cmp=) for better performance.

Modified:
    erp5/trunk/products/ERP5/Document/AmortisationRule.py
    erp5/trunk/products/ERP5/Tool/TemplateTool.py
    erp5/trunk/products/ERP5Type/Core/CacheFactory.py
    erp5/trunk/products/ERP5Type/XMLExportImport.py
    erp5/trunk/products/ERP5Type/patches/XMLExportImport.py

Modified: erp5/trunk/products/ERP5/Document/AmortisationRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AmortisationRule.py?rev=23772&r1=23771&r2=23772&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AmortisationRule.py (original)
+++ erp5/trunk/products/ERP5/Document/AmortisationRule.py Tue Sep 23 21:28:42 2008
@@ -677,7 +677,7 @@
       # We have each matching ratio. Now we need to match each amortisation period
       # according to these ratio : the highest ratio gets the priority, then the next
       # highest is taken into account if corresponding resources are free, and so on
-      matching_ratio_list.sort(lambda a, b: - cmp(a['ratio'], b['ratio']))
+      matching_ratio_list.sort(key=lambda x: -x['ratio'])
       calculated_to_match = calculated_period_dict.keys()
       aggregated_to_match = aggregated_period_dict.keys()
       match_dict = {}

Modified: erp5/trunk/products/ERP5/Tool/TemplateTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/TemplateTool.py?rev=23772&r1=23771&r2=23772&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TemplateTool.py (original)
+++ erp5/trunk/products/ERP5/Tool/TemplateTool.py Tue Sep 23 21:28:42 2008
@@ -824,7 +824,7 @@
                                       repository = repository, **property_dict)
         obj.setUid(uid)
         template_list.append(obj)
-      template_list.sort(lambda x,y:cmp(x.getTitle(), y.getTitle()))
+      template_list.sort(key=lambda x: x.getTitle())
       return template_list
 
     security.declareProtected( Permissions.AccessContentsInformation,

Modified: erp5/trunk/products/ERP5Type/Core/CacheFactory.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/CacheFactory.py?rev=23772&r1=23771&r2=23772&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/CacheFactory.py (original)
+++ erp5/trunk/products/ERP5Type/Core/CacheFactory.py Tue Sep 23 21:28:42 2008
@@ -67,7 +67,7 @@
     """ get ordered list of installed cache plugins in ZODB """
     cache_plugins = self.objectValues(self.allowed_types)
     cache_plugins = map(None, cache_plugins)
-    cache_plugins.sort(lambda x,y: cmp(x.getIntIndex(0), y.getIntIndex(0)))
+    cache_plugins.sort(key=lambda x: x.getIntIndex(0))
     return  cache_plugins
     
   security.declareProtected(Permissions.AccessContentsInformation, 'getRamCacheFactory')

Modified: erp5/trunk/products/ERP5Type/XMLExportImport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/XMLExportImport.py?rev=23772&r1=23771&r2=23772&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/XMLExportImport.py (original)
+++ erp5/trunk/products/ERP5Type/XMLExportImport.py Tue Sep 23 21:28:42 2008
@@ -199,7 +199,7 @@
   xml = xml[:xml.rfind('</object>')]
   # Make sure the list of sub objects is ordered
   object_value_list = list(self.objectValues())
-  object_value_list.sort(lambda x, y: cmp(x.getId(), y.getId()))
+  object_value_list.sort(key=lambda x: x.getId())
   # Append to the xml the xml of subobjects
   for o in object_value_list:
     aq_ob = aq_base(o)

Modified: erp5/trunk/products/ERP5Type/patches/XMLExportImport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/XMLExportImport.py?rev=23772&r1=23771&r2=23772&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/XMLExportImport.py (original)
+++ erp5/trunk/products/ERP5Type/patches/XMLExportImport.py Tue Sep 23 21:28:42 2008
@@ -50,7 +50,7 @@
 
         self.memoize(obj)
         item_list = obj.items() # New version by JPS for sorting
-        item_list.sort(lambda a, b: cmp(a[0], b[0])) # New version by JPS for sorting
+        item_list.sort(key=lambda x: x[0]) # New version by JPS for sorting
         self._batch_setitems(item_list.__iter__())
 
     dispatch[DictionaryType] = save_dict
@@ -160,7 +160,7 @@
                     new_oidict[oid] = getattr(o, 'id', None)
                 except:
                     new_oidict[oid] = None # Ick, a broken reference
-            new_oids.sort(lambda a,b: cmp(new_oidict[a], new_oidict[b]))
+            new_oids.sort(key=lambda x: new_oidict[x])
             # Build new sorted oids
             oids = list(old_oids) + new_oids
     # Do real export




More information about the Erp5-report mailing list