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

Shivaram Lingamneni report at bugs.python.org
Wed Feb 16 17:58:31 EST 2022


Shivaram Lingamneni <slingamn at cs.stanford.edu> 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 performance impact of the initial import of encodings.idna and its transitive dependencies is in fact macroscopic relative to the baseline costs of the interpreter: 5 milliseconds to import the modules and 500 KB in increased RSS, relative to baselines of approximately 50 milliseconds to set up and tear down an interpreter and 10 MB in RSS.

Here are the relevant benchmarks, first for time:


```python
import time
start = time.time()
'a'.encode('idna')
print(time.time() - start)
```

and for memory:

```python
import os
def rss():
    os.system('grep VmRSS /proc/' + str(os.getpid()) + '/status')
rss()
'a'.encode('idna')
rss()
```

Are there potential changes to this patch that would mitigate your concerns?

----------

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


More information about the Python-bugs-list mailing list