From 3b887359395c3c1280cd6ce9ff8657d94861336b Mon Sep 17 00:00:00 2001 From: Christoph Lienhard Date: Tue, 11 Sep 2018 16:10:33 +0200 Subject: [PATCH] slightly faster any() and all() in MultiFields also much more pythonic and horrible for people with origins in other languages --- nifty4/multi/multi_field.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nifty4/multi/multi_field.py b/nifty4/multi/multi_field.py index e806f65e..c61729f6 100644 --- a/nifty4/multi/multi_field.py +++ b/nifty4/multi/multi_field.py @@ -161,16 +161,16 @@ class MultiField(object): return True def any(self): - result = False for field in self._val.values(): - result = result or field.any() - return result + if field.any(): + return True + return False def all(self): - result = True for field in self._val.values(): - result = result and field.all() - return result + if not field.all(): + return False + return True for op in ["__add__", "__radd__", "__iadd__", "__sub__", "__rsub__", "__isub__", -- GitLab