[issue37101] Filterer.filter can be rewritten using built-ins just as efficient much more readable

Dale Visser report at bugs.python.org
Fri May 31 17:42:22 EDT 2019


Dale Visser <dale.visser at live.com> added the comment:

FWIW, when I tried this instead, I got 21 to 22 msec per 1000 log messages (still a 5-10% performance hit):

def filter(self, record):
    rv = True
    if self.filters:
        rv = all(getattr(f, 'filter', f)(record) for f in self.filters)
    return rv

I don't see that getattr(...) should be less efficient than hasattr(...), so the generator expression is the likely culprit.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37101>
_______________________________________


More information about the Python-bugs-list mailing list