Skip to content

Commit

Permalink
perf: cache entry points
Browse files Browse the repository at this point in the history
Without this change, running
`pytest --collect-only --doctest-modules --full-trace`
on https://github.com/NickCrews/mismo takes 2.76s. With this change, it takes 1.21s

This is because every time pytest visits a module during test collection,
it has to determine if each object inside the module is a test. During that process, it calls https://github.com/pytest-dev/pytest/blob/77f2c63a542fc9511f5919ddf7f4b64d237fda07/src/_pytest/python.py#L343, on every item. If I have a module where I do `import ibis`, then this means that we attempt to do `ibis.__test__`, which triggers the `__getattr__` function in `ibis/__init__.py`, which then goes out and loads the entry points. Turns out this is a slow process.
  • Loading branch information
NickCrews committed Feb 24, 2025
1 parent 913fa51 commit 23264f1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ibis/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def experimental(func):
return func


@functools.cache
def backend_entry_points() -> list[importlib.metadata.EntryPoint]:
"""Get the list of installed `ibis.backend` entrypoints."""

Expand Down

0 comments on commit 23264f1

Please sign in to comment.