Proposal: Deprecate codepoint_slices_reversed

Summary

Remove codepoint_slices_reversed in favor of composing reversed() on the result of codepoint_slices().

Motivation

  • API Reduction: Removes specialized “reversed” methods from the main String/Slice API in favor of composable iterator objects.
  • Pythonic Consistency: Aligns with Python’s philosophy where iterators/objects handle their own traversal logic (forward or backward) rather than functions.
    Proposed Changes
  • Update CodepointSliceIter: Ensure this struct implements __reversed__.
  • Deprecate Method: Mark codepoint_slices_reversed as deprecated or remove it entirely.

Usage Comparison

Current (Deprecated):

for s in str.codepoint_slices_reversed():
    print(s)

Proposed:

for s in reversed(str.codepoint_slices()):
    print(s)

In my opinion, this needs to wait until we can properly express ReversableIterator or similar.

2 Likes