From fdc6bd359993b2f06e27cde3d0cfff1df46f624b Mon Sep 17 00:00:00 2001 From: Artur Glavic Date: Mon, 2 Mar 2026 17:12:22 +0100 Subject: [PATCH] Add some comments concerning performance, probably not much to improve --- eos/event_data_types.py | 2 ++ eos/event_handling.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/eos/event_data_types.py b/eos/event_data_types.py index 6d1b9ca..2ccfbf6 100644 --- a/eos/event_data_types.py +++ b/eos/event_data_types.py @@ -46,6 +46,8 @@ EVENT_BITMASKS = { } def append_fields(input: np.recarray, new_fields: List[Tuple[str, np.dtype]]): + # TODO: This action is used often and time consuming as it runs len(flds) times over all indices. + # Could only be faster if array is allocated in the beginning with all fields, less flexible. # add one ore more fields to a recarray, numpy functions seems to fail flds = [(name, dtypei[0]) for name, dtypei in input.dtype.fields.items()] flds += new_fields diff --git a/eos/event_handling.py b/eos/event_handling.py index bb5b9b7..84c70c3 100644 --- a/eos/event_handling.py +++ b/eos/event_handling.py @@ -165,7 +165,9 @@ class ApplyMask(EventDataAction): self.bitmask_filter = bitmask_filter def perform_action(self, dataset: EventDatasetProtocol) ->None: - # TODO: why is this action time consuming? + # TODO: Most time in test examples is spend here. + # While the actions here are very simple, they act on a large array, + # so even just comparison and indexing become time consuming. d = dataset.data pre_filter = d.events.shape[0] if logging.getLogger().level <= logging.DEBUG: