Closed hartwork closed 9 years ago
I believe the slow part of importing requests is importing pyopenssl. In theory you could delay the import until the first time a request is made, though I'm pretty sure the team is not in favor of that approach.
I believe the slow part of importing requests is importing pyopenssl.
That makes perfect sense:
# time python -c 'import OpenSSL.SSL; print OpenSSL.SSL.__file__'
/usr/lib64/python2.7/site-packages/OpenSSL/SSL.pyc
real 0m1.014s
user 0m0.991s
sys 0m0.018s
@hartwork Are you using a new virtualenv for each test? Mostly importing pyopenssl takes a while because cffi does an implicit C compile at import time in some cases, but that should only happen the first time.
No virtualenv over here, no.
# for i in {1..10} ; do sh -c "time python -c 'import OpenSSL.SSL'" |& sed -n '2,2p' ; done
real 0m1.004s
real 0m0.993s
real 0m0.996s
real 0m0.994s
real 0m0.997s
real 0m0.999s
real 0m0.998s
real 0m0.991s
real 0m0.999s
real 0m0.997s
Interesting.
Fundamentally, this is a cryptography
bug, probably pyca/cryptography#1764. I'm afraid until that's resolved we cannot do anything about this.
On my little ARM system from NextThing this takes SEVEN SECONDS.
@afcady Please report the issue to the appropriate upstream.
Hi!
I noticed that the
--help
output of a tool of mine was noticably slower than that of my other tools. It took a full second to show up. I traced the lagging down to the call toimport requests
(and worked around it by importing requests only after processing command line options).import requests
takes at least a second on both the SSDed Debian and HDDed Gentoo, with version 2.5.3 as well as 2.6.0. Compared to the 30 milliseconds that other modules take to import, that's a long time:It would be great if you could work on reducing import time. Many thanks!