Skip to content

DRAFT: libwcwidth portable C11 library - #233

Closed
jquast wants to merge 19 commits into
masterfrom
jq/libwcwidth-experiments
Closed

jquast wants to merge 19 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

codspeed 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.3 µs -10.31%
⚡ test_wcswidth_ri_flags_paired 342.7 ms 5.9 ms ×58
⚡ test_width_ri_flags_paired 342.9 ms 5.9 ms ×58
⚡ test_wcstwidth_ri_term_program[ghostty] 344 ms 6 ms ×58
⚡ test_width_ri_term_program[ghostty] 344.2 ms 6 ms ×57
⚡ test_wcswidth_ri_flags_unpaired 85.9 ms 1.5 ms ×57
⚡ test_wcstwidth_ri_term_program[xterm.js] 345.5 ms 6 ms ×57
⚡ test_width_ri_flags_unpaired 86 ms 1.5 ms ×57
⚡ test_width_ri_term_program[xterm.js] 345.7 ms 6.1 ms ×57
⚡ test_width_udhr 583.9 ms 13.1 ms ×45
⚡ test_wcswidth_decomposed 2,606.2 µs 78.3 µs ×33
⚡ test_width_fastpath_integrity_udhr 733.4 ms 23.1 ms ×32
⚡ test_wcstwidth_emoji_term_program[ghostty] 1,366.8 µs 47.9 µs ×29
⚡ test_wcswidth_composed 1,862.1 µs 68.7 µs ×27
⚡ test_width_udhr_lines 316.2 ms 11.8 ms ×27
⚡ test_wcswidth_brahmic_bengali 1,994.8 µs 80 µs ×25
⚡ test_width_decomposed 2,887.8 µs 116.6 µs ×25
⚡ test_wcswidth_brahmic_devanagari 1,986.1 µs 83.9 µs ×24
⚡ test_width_wcswidth_consistency_udhr 443.4 ms 19.7 ms ×23
⚡ test_width_brahmic_bengali 2,154 µs 96.4 µ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 (ceef701) with master (c0dc90b)

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 (c0dc90b) to head (ceef701).

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         1983     2015      +32     
  Branches       464      469       +5     
===========================================
+ Hits          1983     2011      +28     
- 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.

@jquast

jquast commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #247 and another PR to enable C Python shim, later.

@jquast jquast closed this Sep 15, 2026
@jquast
jquast deleted the jq/libwcwidth-experiments branch September 15, 2026 19:47
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