Commit 44b48bd
committed
gh-118761: Reduce import time of gettext.py by delaying re import
gettext is often imported in programs that may not end up translating
anything. In fact, the `struct` module already has a delayed import when
parsing GNUTranslations to speed up the no .mo files case. The re module
is also used in the same situation, but behind a function chain only
called by GNUTranslations.
cache the compiled regex globally the first time it is used. The
finditer function can be converted to a method call on the compiled
object (it always could) which is slightly more efficient and necessary
for the conditional re import.1 parent d05140f commit 44b48bd
File tree
2 files changed
+19
-14
lines changed- Lib
- Misc/NEWS.d/next/Library
2 files changed
+19
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 73 | + | |
86 | 74 | | |
87 | 75 | | |
88 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments