Skip to content

Commit

Permalink
pre-sort EntryPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Oct 10, 2023
1 parent 0a4b185 commit 1bb0e15
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion aiida/plugins/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 1bb0e15

Please sign in to comment.