Skip to content

utils.module: optimize plugin module loading #5805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2024

Conversation

bastimeyer
Copy link
Member

Minor performance improvement for loading (plugin) modules. This is unrelated to the plugins JSON data loader I've been working on, hence this PR.


  1. utils.module: fix load_module(), add exec_module()
    • Use global finder cache via pkgutil.get_importer() instead of always creating a new FileFinder object for each module
    • Add exec_module() for being able to reuse PathEntryFinder objects returned by pkgutil.iter_modules()
    • Add support for pathlib path objects
    • Update tests
  2. session: re-use PathEntryFinder in load_plugins()
  3. tests: re-use PathEntryFinder in test_plugins

- Use global finder cache via `pkgutil.get_importer()`
  instead of always creating a new `FileFinder` object for each module
- Add `exec_module()` for being able to reuse `PathEntryFinder` objects
  returned by `pkgutil.iter_modules()`
- Add support for pathlib path objects
- Update tests
@bastimeyer bastimeyer merged commit c45bf3c into streamlink:master Jan 29, 2024
@bastimeyer bastimeyer deleted the utils/module/optimize branch January 29, 2024 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant