psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.19k stars 9.33k forks source link

Import time regression #6790

Open holmanb opened 3 months ago

holmanb commented 3 months ago

Between 2.31.0 and 2.32.3, import time increased by ~25%. This appears to have been caused by https://github.com/psf/requests/pull/6667, which changed the expensive load_verify_locations() to run at import time (in 2.32.0).

Reproduction Steps

Compare import time of versions with:

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

2.31.0

image

2.32.3:

image

donno commented 2 weeks ago

I'm on Windows, with Python 3.11 and requests 2.32.3 and noticed very slow import times and narrowed it down to requests. In my case when importing requests, the requests.adapters module made up 4.353 s (85.9%) of the import time with similar command as above.