Skip to content

New functions: iter_graphemes_reverse(), grapheme_boundary_before()#192

Merged
jquast merged 6 commits intomasterfrom
jq/reverse-iter-graphemes
Jan 26, 2026
Merged

New functions: iter_graphemes_reverse(), grapheme_boundary_before()#192
jquast merged 6 commits intomasterfrom
jq/reverse-iter-graphemes

Conversation

@jquast
Copy link
Copy Markdown
Owner

@jquast jquast commented Jan 26, 2026

As I audit and integrate with dependent libraries, in urwid I find the need to help "move the cursor left" and look backwards from a location in a string to the previous boundary, while looking forward using iter_graphemes().

Looking backwards is provided by new function grapheme_boundary_before().

The more obvious function, iter_graphemes_reverse() is provided (though not useful to urwid). @penguinolog

late-binding or 'late-slicing' ?
As I integrate with downstream libraries, in urwid in particular, I find
the to help them "move the cursor left" and look backwards from a
location in a string to the previous boundary,
grapheme_boundary_before().  The more obvious function,
iter_graphemes_reverse() is provided, with examples
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 26, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing jq/reverse-iter-graphemes (22f0211) with master (b1cdbdf)

Summary

✅ 38 untouched benchmarks
🆕 9 new benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_wcswidth_decomposed N/A 2.3 ms N/A
🆕 test_width_decomposed N/A 2.6 ms N/A
🆕 test_width_composed N/A 2 ms N/A
🆕 test_grapheme_boundary_before_long_end N/A 82.3 µs N/A
🆕 test_grapheme_boundary_before_long_mid N/A 79.3 µs N/A
🆕 test_iter_graphemes_reverse_long N/A 473.4 µs N/A
🆕 test_grapheme_boundary_before_short N/A 76.7 µs N/A
🆕 test_iter_graphemes_reverse_short N/A 94.8 µs N/A
🆕 test_wcswidth_composed N/A 1.8 ms N/A

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 26, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #192   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines          618       668   +50     
  Branches       150       164   +14     
=========================================
+ Hits           618       668   +50     

☔ 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 jquast force-pushed the jq/reverse-iter-graphemes branch from 4596e04 to 030cff2 Compare January 26, 2026 02:21
@jquast jquast force-pushed the jq/reverse-iter-graphemes branch from 030cff2 to 22f0211 Compare January 26, 2026 02:22
@jquast jquast marked this pull request as ready for review January 26, 2026 02:28
@jquast jquast merged commit b297eaf into master Jan 26, 2026
43 checks passed
@jquast jquast deleted the jq/reverse-iter-graphemes branch January 26, 2026 02:32
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