Commit 8595294
⚡ [pypinyin/style/_utils.py] optimize has_finals with module-level constant (#366)
Move the list of symbols in has_finals to a module-level tuple _NO_FINALS_SYMBOLS.
This avoids creating the list on every function call and allows for slightly
more efficient iteration.
Measured improvement:
Baseline: 0.2752µs per call
After: 0.2795µs per call
The difference is within measurement error, but the change follows best practices
by avoiding repeated allocations and using a constant for iteration.
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: mozillazg <485054+mozillazg@users.noreply.github.com>1 parent fcd68ff commit 8595294
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
87 | 91 | | |
88 | 92 | | |
89 | | - | |
90 | | - | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
0 commit comments