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

2022-02-16 Thread Shivaram Lingamneni
Shivaram Lingamneni added the comment: I wanted to check in about the status of this patch. Here's the case for the patch, as I understand it: 1. It is not a novel optimization, it just consistently applies design decisions that were made previously (RFE #1472176 and bpo-22127). 2. The perfo

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

2022-02-14 Thread Shivaram Lingamneni
Shivaram Lingamneni added the comment: (Looks like it was 15 milliseconds when measuring inside `python -i`; I'm not sure what the root cause of the difference is, but clearly the 5 millisecond measurement from regular `python` is more accurate.) -- _

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

2022-02-14 Thread Shivaram Lingamneni
Shivaram Lingamneni added the comment: Sorry, I should have been more clear: I am including the initial costs of importing stringprep and unicodedata. On my system: $ python3 -c "import time; start = time.time(); r = 'a'.encode('idna'); elapsed = time.time() - start; print(elapsed)" 0.005380

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

2022-02-14 Thread Christian Heimes
Christian Heimes added the comment: It's 100 times faster. The initial import takes about 150 μsec (0.15msec) and it's a one time cost. IDNA encoding of a typical hostname is about 70nsec. A DNS lookup is three magnitudes slower. -- ___ Python trac

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

2022-02-14 Thread Shivaram Lingamneni
Shivaram Lingamneni 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 exa

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

2022-02-14 Thread Christian Heimes
Christian Heimes added the comment: Please provide benchmarks and data for your claim that encodings.idna is a performance bottleneck. encodings.idna is a simple, short module without state. On my system it takes about 0.15 msec to import the module. When unicodedata and stringprep aren't l

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

2022-02-14 Thread Shivaram Lingamneni
Change by Shivaram Lingamneni : -- keywords: +patch pull_requests: +29484 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31328 ___ Python tracker

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

2022-02-14 Thread Shivaram Lingamneni
New submission from Shivaram Lingamneni : Importing the idna encoding has a significant time and memory cost. Therefore, the standard library tries to avoid importing it when it's not needed (i.e. when the domain name is already pure ASCII), e.g. in Lib/http/client.py and Modules/socketmodule