Skip to content

wcwidth 0.9.2 integration - #420

Open
jquast wants to merge 13 commits into
masterfrom
jq/wcwidth-0.9.1
Open

jquast wants to merge 13 commits into
masterfrom
jq/wcwidth-0.9.1

Conversation

@jquast

@jquast jquast commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner
  • wcwidth 0.9.2 integration, ~2-15x performance improvement to text alignment
  • bumps python-requires to 3.9 to match wcwidth's
  • uses terminal-specific correction tables for alignment functions
  • adds conditional XTVERSION query on class initialization
    • if TERM_PROGRAM environment value is defined, no query is made
  • add clip() as more direct wrapper of wcwidth.clip(), a better 'truncate()', requested in Terminal.truncate moves sequence to end of string #402
  • adds ambiguous width in alignment support, but not by default (documented)
    • calling detect_ambiguous_width() after class initialization auto-applies the results to alignment function

alignments for the below varies among all identifiable terminals, but are now aligned, 10 of them on linux in screenshot below:

Screenshot_20261001_161838

Unidentifiable terminals continue to be out of alignment sometimes, they can't be helped:

image

Actually, there are many more ways to identify a terminal, at least ENQ, and some terminal authors even believe DA1 response, but I think it is best to support only the progressive/modern methods. And these are the only kinds of terminals supported by wcstwidth() anyway.

@codspeed

codspeed Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by ×3.8

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 19 improved benchmarks
✅ 12 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_length_emoji_vs16 672.5 µs 43.8 µs ×15
⚡ test_length_cjk 770.2 µs 69.7 µs ×11
⚡ test_truncate_emoji_zwj 966.1 µs 89.7 µs ×11
⚡ test_length_emoji_zwj 188 µs 28.5 µs ×6.6
⚡ test_center_cjk 780.1 µs 130.4 µs ×6
⚡ test_ljust_cjk 778.3 µs 130.7 µs ×6
⚡ test_rjust_cjk 777.8 µs 131 µs ×5.9
⚡ test_truncate_cjk 518.7 µs 97.5 µs ×5.3
⚡ test_center_ansi 389.2 µs 108.2 µs ×3.6
⚡ test_rjust_ansi 382.7 µs 108 µs ×3.5
⚡ test_ljust_ansi 381.1 µs 108.3 µs ×3.5
⚡ test_center_emoji_zwj 206 µs 69.1 µs ×3
⚡ test_rjust_emoji_zwj 202.7 µs 69.1 µs ×2.9
⚡ test_ljust_emoji_zwj 202.8 µs 69.2 µs ×2.9
⚡ test_length_ansi 373.4 µs 170.2 µs ×2.2
⚡ test_center_ascii 47 µs 34.7 µs +35.42%
⚡ test_rjust_ascii 43.6 µs 34.6 µs +25.97%
⚡ test_ljust_ascii 43.6 µs 34.7 µs +25.71%
⚡ test_length_ascii 37 µs 31.2 µs +18.41%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jq/wcwidth-0.9.1 (f55f278) with master (362dbe2)

Open in CodSpeed

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.29078% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.75%. Comparing base (362dbe2) to head (f55f278).

Files with missing lines Patch % Lines
blessed/terminal.py 98.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #420      +/-   ##
==========================================
+ Coverage   97.72%   97.75%   +0.02%     
==========================================
  Files          13       13              
  Lines        4052     4106      +54     
  Branches      739      695      -44     
==========================================
+ Hits         3960     4014      +54     
+ Misses         71       70       -1     
- Partials       21       22       +1     

☔ View full report in Codecov by Harness.
📢 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.

@jquast

This comment was marked as off-topic.

@jquast
jquast marked this pull request as ready for review October 5, 2026 00:37
@jquast jquast changed the title wcwidth 0.9.1 integration wcwidth 0.9.2 integration Oct 5, 2026
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.

1 participant