Skip to content

DRAFT: libwcwidth portable C11 library - #233

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

DRAFT: libwcwidth portable C11 library#233
jquast wants to merge 13 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 improve performance by ×9.3

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

⚡ 58 improved benchmarks
✅ 50 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_wcswidth_ri_flags_paired 343.4 ms 5.9 ms ×58
test_wcstwidth_ri_term_program[ghostty] 344.6 ms 6 ms ×58
test_wcswidth_ri_flags_unpaired 86.1 ms 1.5 ms ×57
test_wcstwidth_ri_term_program[xterm.js] 346.1 ms 6 ms ×57
test_width_ri_flags_paired 343.6 ms 6 ms ×57
test_width_ri_term_program[ghostty] 344.8 ms 6.1 ms ×56
test_width_ri_term_program[xterm.js] 346.3 ms 6.2 ms ×56
test_width_ri_flags_unpaired 86.2 ms 1.6 ms ×55
test_wcswidth_decomposed 2,591.4 µs 78.2 µs ×33
test_wcstwidth_emoji_term_program[ghostty] 1,366 µs 47.2 µs ×29
test_width_udhr 585.6 ms 20.4 ms ×29
test_wcswidth_composed 1,865.4 µs 68.5 µs ×27
test_wcswidth_brahmic_bengali 1,981.3 µs 79.9 µs ×25
test_wcswidth_brahmic_devanagari 1,973.9 µs 83.7 µs ×24
test_wcstwidth_vs15_term_program[xterm.js] 1,045.1 µs 62.8 µs ×17
test_wcstwidth_emoji_term_program[xterm.js] 551.8 µs 33.4 µs ×17
test_wcstwidth_vs15_term_program[ghostty] 776 µs 49.9 µs ×16
test_wcstwidth_vs16_term_program[xterm.js] 955.5 µs 61.9 µs ×15
test_ljust_udhr_lines 319.3 ms 20.9 ms ×15
test_width_fastpath_integrity_udhr 734.7 ms 49.9 ms ×15
... ... ... ... ...

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

Tip

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


Comparing jq/libwcwidth-experiments (8a6c494) with master (551710e)

Open in CodSpeed

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (551710e) to head (8a6c494).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #233   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         1973      1990   +17     
  Branches       464       467    +3     
=========================================
+ Hits          1973      1990   +17     

☔ 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 and others added 3 commits August 7, 2026 17:04
…ith 'import' and 'import from''

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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