diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 16812ec8d5..5e04408475 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -801,16 +801,9 @@ class Filterer(object): Allow filters to be just callables. """ - rv = True - for f in self.filters: - if hasattr(f, 'filter'): - result = f.filter(record) - else: - result = f(record) # assume callable - will raise if not - if not result: - rv = False - break - return rv + filters = (getattr(f, 'filter', f) for f in self.filters) + return all(f(record) for f in filters) # assume callable - will raise if not + #--------------------------------------------------------------------------- # Handler classes and functions diff --git a/Misc/NEWS.d/next/Library/2019-05-30-13-02-31.bpo-37101.pJ8FSq.rst b/Misc/NEWS.d/next/Library/2019-05-30-13-02-31.bpo-37101.pJ8FSq.rst new file mode 100644 index 0000000000..3df7eac660 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-05-30-13-02-31.bpo-37101.pJ8FSq.rst @@ -0,0 +1 @@ +Improved the efficiency of :mod:`logging` record filtering.