-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
python -c "import requests" got a lot slower #4278
Comments
I found this similar issue: #3213 maybe it's relevant. |
What other packages do you have installed? Specifically, it's likely that you have ancient versions of pyOpenSSL and Cryptography installed which are causing this. |
After upgarding pyOpenSSL from 16.2 to 17.2 (which implicitly upgraded cryptography to 2.0.3, not sure from which previous version) and using latest requests version (2.18.4) the time improved to:
That is still, however, considerably larger than what requests-2.11.1 used to be. Do you have any other ideas? |
Now the python -m requests.help worked on the latest version, here is the output:
|
There are a lot of changes between 2.11.x and the latest version. For example, we now depend on idna as well which if I remember correctly used to also be rather slow to import. I wonder what kind of performance you see if you use a virtualenv without pyOpenSSL installed with 2.18.x |
We should warn on old pyOpenSSLs for slowness. |
I'd like to add warnings for older versions pyOpenSSL. Should I open a new issue? |
yes |
Still, warning won't solve twice as long time for importing than it used to be in older versions... Is there something more that could be done? |
Related: #4315 |
One big change between 2.11 and 2.12 is |
But chardet takes only 10~20% of import time on amd64 machine. @gtrainavicius Could you try And could you try |
The output is available here: https://pastebin.com/qAvhRbVK |
L325 imports Can you try the following:
If you're still using the versions of our dependencies that you mentioned, I'm frankly surprised you're seeing this behaviour. |
Hey, the versions did change, pasting the updated information below. Also the above requests-import.txt was produced running requests-2.12.4. Just in case I will create another one using the latest version (requests-2.18.4): https://pastebin.com/3fdTuyR1 - it also contains 'import' time info at the top.
Here are the cryptography import timings:
|
Yep, so as I expected, there's a total of .995s just in Cryptography (and its imports). With chardet at .05 that puts us over 1s easily. It's possible that the chardet import may get slower. We're investigating relying on CFFI or Cython to improve its performance. @gtrainavicius I wonder, you're using Python 2.7.13 and you have pyOpenSSL installed, is there a reason for that? |
No reason, pyOpenSSL was installed by default on Raspbian, though not the latest version. What we really want is to have requests library as fast as in the older versions, in our scripts that depend on it we're not using almost any other libraries... |
@gtrainavicius the problem, however, is that Requests expects users to manage their environment appropriately. This means that we expect users to know if we need |
Ah, it didn't occur to me that pyOpenSSL was optional. With it uninstalled, the time to import requests seems close enough to what it used to be: pi@raspberrypi:~ $ time python -c 'import requests' real 0m0.488s |
We have noticed that 'import requests' statement started taking roughly 3 times more time between versions 2.12.0 (bad) and 2.11.1 (last known good), the difference is especially visible running on Raspberry Pi 3.
Expected Result
'import requests' execution time should not increase by 3-4 times between versions.
Actual Result
3-4 times slower 'import requests' execution.
Reproduction Steps
System Information
Raspbian Stretch.
The text was updated successfully, but these errors were encountered: