From 67a3df94a66a35aff711b9db824487d4bc318586 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 10 Jun 2023 23:50:03 +0100 Subject: [PATCH] reduce number of lines slightly by using yield from filter(match, ...) --- src/openpower/insndb/core.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index 21f5cc48..d19f92a5 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -108,9 +108,8 @@ class Tuple(Node, tuple): if isinstance(clsself, type): yield ("[]", clsself.__datatype) else: - for (index, item) in enumerate(clsself): - if match(item): - yield (str(index), item) + for (index, item) in enumerate(filter(match, clsself)): + yield (str(index), item) class Dict(Node, dict): @@ -144,9 +143,7 @@ class Dict(Node, dict): if isinstance(clsself, type): yield ("{}", clsself.__datatype) else: - for (key, value) in clsself.items(): - if match(value): - yield (key, value) + yield from filter(lambda kv: match(kv[0]), clsself.items()) class VisitorMethod: -- 2.30.2