Skip to content

DRAFT: libwcwidth portable C11 library - #233

Draft
jquast wants to merge 16 commits into
masterfrom
jq/libwcwidth-experiments
Draft

DRAFT: libwcwidth portable C11 library#233
jquast wants to merge 16 commits into
masterfrom
jq/libwcwidth-experiments

Conversation

@jquast

@jquast jquast commented Aug 6, 2026

Copy link
Copy Markdown
Owner

I am creating a draft PR for the purpose of working with CI workflows of building wheels and to see performance results of codspeed.

This is only a draft, and will be under review and revision for a while longer, especially the documentation.

jquast added 4 commits July 26, 2026 21:43
Port width/wcswidth/wcstwidth, wrap, clip, escape, and SGR to C11
(libwcwidth) with utf8 or codepoints/u32 API's, and and codepoints/u32
terminal override support.

Note that for the higher level functions, the u32 variants are slow --
they convert to utf8 then back to u32, and so the utf8 functions are
preferred.

Exposed the C11 library as an optional CPython extension, which should
drastically improve python wcwidth performance, though the real aim was
to use the existing python tests and frameworks (ucs-detect) to exercise
and verify the C11 code.
@jquast
jquast force-pushed the jq/libwcwidth-experiments branch from b2d9a66 to 3998d25 Compare August 7, 2026 01:52
Comment thread tests/test_textwrap.py Fixed
@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown

Merging this PR will regress 1 benchmark

⚠️ 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

⚡ 59 improved benchmarks
❌ 1 regressed benchmark
✅ 48 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
test_clip_ascii 21.8 µs 24.4 µs -10.74%
test_wcswidth_ri_flags_paired 343.3 ms 5.9 ms ×58
test_width_ri_flags_paired 343.5 ms 5.9 ms ×58
test_wcstwidth_ri_term_program[ghostty] 344.5 ms 6 ms ×58
test_width_ri_term_program[ghostty] 344.7 ms 6 ms ×57
test_wcswidth_ri_flags_unpaired 86.1 ms 1.5 ms ×57
test_wcstwidth_ri_term_program[xterm.js] 346 ms 6 ms ×57
test_width_ri_flags_unpaired 86.2 ms 1.5 ms ×57
test_width_ri_term_program[xterm.js] 346.2 ms 6.1 ms ×57
test_width_udhr 585.4 ms 13.1 ms ×45
test_wcswidth_decomposed 2,607.3 µs 78.4 µs ×33
test_width_fastpath_integrity_udhr 734.6 ms 23.3 ms ×32
test_wcstwidth_emoji_term_program[ghostty] 1,363.5 µs 47.8 µs ×29
test_wcswidth_composed 1,866.4 µs 68.6 µs ×27
test_width_udhr_lines 316.5 ms 11.8 ms ×27
test_wcswidth_brahmic_bengali 1,986 µs 80.1 µs ×25
test_width_decomposed 2,891.6 µs 118.1 µs ×24
test_wcswidth_brahmic_devanagari 1,982.3 µs 83.9 µs ×24
test_width_wcswidth_consistency_udhr 443.6 ms 19.8 ms ×22
test_width_brahmic_bengali 2,146.3 µs 96.7 µs ×22
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing jq/libwcwidth-experiments (8fdbb2a) with master (17986f5)

Open in CodSpeed

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.80%. Comparing base (17986f5) to head (8fdbb2a).

Files with missing lines Patch % Lines
wcwidth/_constants.py 50.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##            master     #233      +/-   ##
===========================================
- Coverage   100.00%   99.80%   -0.20%     
===========================================
  Files           27       27              
  Lines         1976     2010      +34     
  Branches       463      468       +5     
===========================================
+ Hits          1976     2006      +30     
- Misses           0        2       +2     
- Partials         0        2       +2     

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

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