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

Optimize Import Time for Requests Library #96

Closed
wants to merge 1 commit into from

Conversation

dosine-staging[bot]
Copy link

@dosine-staging dosine-staging bot commented Sep 2, 2024

This pull request addresses the issue of increased import time in the Requests library, which was observed to have increased by approximately 25% between versions 2.31.0 and 2.32.3. The increase was identified to be caused by the change in psf#6667, which made the load_verify_locations() function run at import time.

Changes Made:

  • Removed unnecessary imports and docstrings to streamline the import process.
  • Deferred the initialization of certain variables and functions to reduce the initial import overhead.
  • Added DEFAULT_SSL_CIPHERS and init_poolmanager function to handle SSL ciphers and pool manager initialization more efficiently.

These changes aim to optimize the import time without affecting the functionality of the library. The import time can be compared using the following commands:

$ python3 -X importtime -c 'import requests' 2> requests_import.log
$ tuna requests_import.log

@SamStenner SamStenner closed this Sep 2, 2024
@SamStenner SamStenner deleted the cosine/fix/import-time-increase branch September 2, 2024 13:31
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.

1 participant