Thanks to visit codestin.com
Credit goes to github.com

Skip to content

utils.module: optimize plugin module loading#5805

Merged
bastimeyer merged 3 commits into
streamlink:masterfrom
bastimeyer:utils/module/optimize
Jan 29, 2024
Merged

utils.module: optimize plugin module loading#5805
bastimeyer merged 3 commits into
streamlink:masterfrom
bastimeyer:utils/module/optimize

Conversation

@bastimeyer

Copy link
Copy Markdown
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