[issue46750] some code paths in ssl and _socket still import idna unconditionally

Shivaram Lingamneni report at bugs.python.org
Mon Feb 14 12:00:34 EST 2022


Shivaram Lingamneni <slingamn at cs.stanford.edu> added the comment:

Thanks for the prompt response. As evidence that this was of concern to the development team in the past, here's an issue where the unnecessary import of idna was treated as a regression:

https://bugs.python.org/issue22127

The discussion there also examines the semantic change produced by the optimization (some invalid labels making it to a DNS lookup instead of being rejected) and doesn't consider it to be a breaking change (albeit a reason not to backport).

(I also see references in documentation to a discussion labeled "RFE #1472176", but am unable to find the actual bug tracker or database entry this refers to.)

A time cost of 15 milliseconds seems accurate to me. The RAM cost on my release build of Python 3.8.10 is about 600 KB in RSS (this is approximately 5% of the baseline interpreter usage).

I cannot reproduce the claim that `urllib.parse` imports stringprep or unicodedata:

    python3 -c "import sys, urllib.parse; assert 'stringprep' not in sys.modules"

    python3 -c "import sys, urllib.parse; assert 'unicodedata' not in sys.modules"

I am developing a new lightweight http library that does use urllib.parse; on my system, these patches allow it to function without importing stringprep, idna, or unicodedata:

https://github.com/slingamn/mureq

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46750>
_______________________________________


More information about the Python-bugs-list mailing list