From 0dfe7e25a58c950f5768a06ae12898a008fff738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 6 Jul 2025 19:46:34 +0200 Subject: [PATCH] [util] slightly improve 'filter' performance --- gallery_dl/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gallery_dl/util.py b/gallery_dl/util.py index f06668f9..0a1c4f87 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -831,10 +831,12 @@ def compile_expression_defaultdict_impl(expr, name="", globals=None): def compile_expression_tryexcept(expr, name="", globals=None): code_object = compile(expr, name, "eval") + if globals is None: + globals = GLOBALS - def _eval(locals=None, globals=(globals or GLOBALS), co=code_object): + def _eval(locals=None): try: - return eval(co, globals, locals) + return eval(code_object, globals, locals) except exception.GalleryDLException: raise except Exception: