[optimisation] _select_best is used very intensivly. Peanuts optimization may count :) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 31 Mar 2010 09:58:20 +0200
branchstable
changeset 5095 eaf522b9b998
parent 5094 13b7f30db0bb
child 5096 e25979a6d795
[optimisation] _select_best is used very intensivly. Peanuts optimization may count :)
vregistry.py
--- a/vregistry.py	Wed Mar 31 09:57:18 2010 +0200
+++ b/vregistry.py	Wed Mar 31 09:58:20 2010 +0200
@@ -210,14 +210,14 @@
         if len(args) > 1:
             warn('[3.5] only the request param can not be named when calling select*',
                  DeprecationWarning, stacklevel=3)
-        score, winners = 0, []
+        score, winners = 0, None
         for appobject in appobjects:
             appobjectscore = appobject.__select__(appobject, *args, **kwargs)
             if appobjectscore > score:
                 score, winners = appobjectscore, [appobject]
             elif appobjectscore > 0 and appobjectscore == score:
                 winners.append(appobject)
-        if not winners:
+        if winners is None:
             raise NoSelectableObject('args: %s\nkwargs: %s %s'
                                      % (args, kwargs.keys(),
                                         [repr(v) for v in appobjects]))