Skip to content

Commit 7daa92e

Browse files
ichard26sethmlarson
authored andcommitted
perf: don't check for peer certificate chain APIs on CPython/PyPy
create_default_context() is quite slow on Linux as OpenSSL 3.x verify location loading is painfully slow. I've observed ~15 ms per call. On CPython and PyPy, we can skip this check since we already know the required APIs exist.
1 parent 8e86b91 commit 7daa92e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/truststore/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Detect Python runtimes which don't implement SSLObject.get_unverified_chain() API
99
# This API only became public in Python 3.13 but was available in CPython and PyPy since 3.10.
10-
if _sys.version_info < (3, 13):
10+
if _sys.version_info < (3, 13) and _sys.implementation.name not in ("cpython", "pypy"):
1111
try:
1212
import ssl as _ssl
1313
except ImportError:

0 commit comments

Comments
 (0)