Skip to content
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

Ensure that pkg_resources.working_set (.entries) load lazily #1

Open
wants to merge 1 commit into
base: python2-main
Choose a base branch
from

Conversation

Alphadelta14
Copy link
Owner

Summary of changes

Speed up how long it takes to import pkg_resources by deferring load of WorkingSet.entries until they are needed (for e.g., iter_entry_points)

Importing pkg_resources requires a full traversal of all sys.paths and loading all contextual metadata for all packages and this can be quite slow under many many circumstances.

Closes pypa#510
Closes pypa#711
Closes pypa#926

Unlikely to pursue upstream merge as this targets both Python 2.7 and 3.7.

Pull Request Checklist

  • Changes have tests
  • News fragment added in changelog.d. See documentation for details

@thomasaarholt
Copy link

Having just gone down the rabbit hole of looking as to why pkg_resources is slow to import, I arrived at this. I observe that you've created this PR to your own repo. Is this intentional, or were you intending to submit it to pypa/setuptools? I would be very interested in seeing pkg_resources imports sped up :)

@Alphadelta14
Copy link
Owner Author

@thomasaarholt I needed fixes for Python 2, so that's why I didn't direct upstream. But I guess with interest i could switch targets to there.
I was a bit discourged since pypa#510 was closed as WontFix though.

@thomasaarholt
Copy link

I'd argue that that issue went on for too long in a slightly unhealthy manner.

If your code does either load things lazily or speed it up in some manner, I'd imagine there would be people glad to see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants