From 1bb0e15829fc5b08c03b9d069d01b5970930a88d Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 10 Oct 2023 02:52:21 +0100 Subject: [PATCH] pre-sort EntryPoints --- aiida/plugins/entry_point.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/aiida/plugins/entry_point.py b/aiida/plugins/entry_point.py index 36ccc1d408..4cf74ab7cd 100644 --- a/aiida/plugins/entry_point.py +++ b/aiida/plugins/entry_point.py @@ -8,6 +8,8 @@ # For further information please visit http://www.aiida.net # ########################################################################### """Module to manage loading entrypoints.""" +from __future__ import annotations + import enum import functools import traceback @@ -32,7 +34,17 @@ @functools.cache def eps() -> EntryPoints: - return _eps() + """Cache around entry_points() + + This call takes around 50ms! + NOTE: For faster lookups, we sort the ``EntryPoints`` alphabetically + by the group name so that 'aiida.' groups come up first. + Unfortunately, this does not help with the entry_points.select() filter, + which will always iterate over all entry points since it looks for + possible duplicate entries. + """ + entry_points = _eps() + return EntryPoints(sorted(entry_points, key=lambda x: x.group)) @functools.lru_cache(maxsize=100)