Skip to content

Add fast path for ASCII printables to width()#185

Merged
jquast merged 1 commit intojquast:masterfrom
hugovk:master
Jan 23, 2026
Merged

Add fast path for ASCII printables to width()#185
jquast merged 1 commit intojquast:masterfrom
hugovk:master

Conversation

@hugovk
Copy link
Copy Markdown
Contributor

@hugovk hugovk commented Jan 23, 2026

Similar to #171 's improvement to wcswidth()

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 23, 2026

Merging this PR will improve performance by ×2

⚡ 5 improved benchmarks
✅ 33 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_width_ascii 42 µs 20.7 µs ×2
test_wrap_short_ascii 349.9 µs 249.9 µs +40.04%
test_wrap_long_text 4.3 ms 2.7 ms +59.06%
test_wrap_with_ansi 363.2 µs 278.4 µs +30.44%
test_wrap_udhr 655.5 ms 572.2 ms +14.56%

Comparing hugovk:master (315ce5e) with master (4738d79)

Open in CodSpeed

@hugovk
Copy link
Copy Markdown
Contributor Author

hugovk commented Jan 23, 2026

codspeed looks like a good tool!

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4738d79) to head (315ce5e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #185   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          604       606    +2     
  Branches       145       146    +1     
=========================================
+ Hits           604       606    +2     

☔ 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.

@jquast
Copy link
Copy Markdown
Owner

jquast commented Jan 23, 2026

Yes it is pretty nice, it was @avylove and @grayjk's idea, thanks for the performance boost

@jquast jquast merged commit 9c3356e into jquast:master Jan 23, 2026
43 checks passed
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.

2 participants