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

Dale Visser report at bugs.python.org
Sat Jun 1 09:08:51 EDT 2019


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

I've learned a lot about the performance trade-offs of generator expressions. The only way of shortening this code (readability is subjective) that I've found not to negatively impact performance is this:

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

----------

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


More information about the Python-bugs-list mailing list