Slow IDNA encoding with large strings
Author: encukouCreated Sep 17, 2026Updated Sep 17, 2026
Labelstype-featurestdlib
This is the opposite of #98433 which concerned IDNA decoding.
IDNA uses the quadratic-complexity codec punycode, making it slow with large inputs.
We do check the limit (64 bytes per label), but too late (after the quadratic step is done).
Note that #155475 added documentation warnings, urging users to limit the input size:
- https://docs.python.org/3/library/codecs.html#text-encodings
- https://docs.python.org/3/library/codecs.html#module-encodings.idna
Linked PRs
- gh-157682
Source: python/cpython