Skip to content

Remove all but latest unicode version#195

Merged
jquast merged 5 commits intomasterfrom
jq/remove-older-tables
Jan 27, 2026
Merged

Remove all but latest unicode version#195
jquast merged 5 commits intomasterfrom
jq/remove-older-tables

Conversation

@jquast
Copy link
Copy Markdown
Owner

@jquast jquast commented Jan 27, 2026

Closes #190.

By our cautious use of list_versions() and other public API's, safely ignore any unicode_version argument or UNICODE_VERSION environment variable. No such things are ever processed. maybe this improves performance of the very first call.

A 20-30% performance boost is found by careful study of an lru_cache performance issue, by careful construction of positional only arguments, of fewest possible positions in the common case (ambiguous_width=1, and unicode_version='auto'). This "performance boost" would have worked with multiple versions, too, a nice discovery.

By our cautious use of list_versions() and other public API's, safely
ignore any ``unicode_version`` argument or ``UNICODE_VERSION``
environment variable. No such things are ever processed. maybe this
improves performance of the very first call.

One small regret, that we cannot just delete the keyword argument from
the signature and stop documenting about it while also ignoring any use,
which could reduce its overhead in lru_cache, but I couldn't find a
solution that wouldn't also raise TypeError or have some other
performance impact.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 27, 2026

Merging this PR will improve performance by 25.73%

⚡ 9 improved benchmarks
✅ 47 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_wcswidth_decomposed 2.3 ms 1.8 ms +25.73%
test_width_decomposed 2.6 ms 2.1 ms +22.16%
test_wcswidth_long_japanese 279 µs 230.9 µs +20.84%
test_width_udhr 138.9 ms 115.4 ms +20.38%
test_width_composed 2 ms 1.7 ms +21.72%
test_rjust_udhr_lines 1.8 ms 1.5 ms +18.12%
test_wcswidth_composed 1.8 ms 1.4 ms +24.87%
test_ljust_udhr_lines 1.8 ms 1.5 ms +18.2%
test_center_udhr_lines 1.9 ms 1.6 ms +16.7%

Comparing jq/remove-older-tables (9cd3f33) with master (70dd591)

Open in CodSpeed

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.53%. Comparing base (70dd591) to head (9cd3f33).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
+ Coverage   98.36%   98.53%   +0.16%     
==========================================
  Files          14       14              
  Lines         919      889      -30     
  Branches      234      225       -9     
==========================================
- Hits          904      876      -28     
- Misses          6        7       +1     
+ Partials        9        6       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lru_cache, it seems, is very peculiar about its positional arguments, so
we define a single-positioned cache in (default) case of
ambiguous_width=1, and otherwise we must also use the positional case of
(c, 'auto', ambiguous_width).
@jquast jquast changed the title Safely Remove all but latest unicode version Safely Remove all but latest unicode version, and small performance boost Jan 27, 2026
@jquast jquast changed the title Safely Remove all but latest unicode version, and small performance boost Remove all but latest unicode version Jan 27, 2026
@jquast jquast merged commit 4ad63d0 into master Jan 27, 2026
39 checks passed
@jquast jquast deleted the jq/remove-older-tables branch January 27, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop all but latest unicode table versions, reducing package size

2 participants