Skip to content

Conversation

@Yu-zh
Copy link
Collaborator

@Yu-zh Yu-zh commented Oct 30, 2025

This PR Implements MutArrayView[T], a zero-copy mutable view type that provides read-write access to array slices without copying data.

Major Changes:

  • New type: MutArrayView[T] - a builtin valtype representing a mutable window into arrays
  • Core operations:
    • Element access: at()/[] and set()/[]= with bounds checking
    • Unsafe operations: unsafe_get() and unsafe_set() for performance-critical code
    • View creation: mut_sub() method for Arrays, FixedArrays, and MutArrayViews
    • Read-only conversion: sub()/[:] to convert to immutable ArrayView
  • Iterator support: Added iterator(), rev_iterator(), and iterator2() implementations
  • Trait implementations: Show, Eq, Compare, and Hash
  • Negative index support: Enables Python-style negative indexing (e.g., arr.mut_sub(start=-3, end=-1))
  • For the rest of APIs that ArrayView[T] has but not implemented for MutArrayView[T], user can first take view from MutArrayView[T] and then use ArrayView[T]'s API.

@Yu-zh Yu-zh marked this pull request as draft October 30, 2025 02:48
@Yu-zh Yu-zh marked this pull request as ready for review October 31, 2025 05:40
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 1688

Details

  • 34 of 55 (61.82%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 89.763%

Changes Missing Coverage Covered Lines Changed/Added Lines %
builtin/mutarrayview.mbt 34 38 89.47%
array/mutview.mbt 0 17 0.0%
Totals Coverage Status
Change from base Build 1687: -0.04%
Covered Lines: 9979
Relevant Lines: 11117

💛 - Coveralls

@Yu-zh Yu-zh marked this pull request as draft October 31, 2025 07:41
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.

3 participants