Skip to content

Document tobytes() copy behavior in NumPy array hashing#343

Merged
shaypal5 merged 2 commits intocodex/add-test-and-benchmark-for-numpy-array-performancefrom
copilot/sub-pr-337-again
Feb 18, 2026
Merged

Document tobytes() copy behavior in NumPy array hashing#343
shaypal5 merged 2 commits intocodex/add-test-and-benchmark-for-numpy-array-performancefrom
copilot/sub-pr-337-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 18, 2026

The _hash_numpy_array function uses tobytes(order="C") to ensure consistent hashing regardless of memory layout, but this can incur a copy for non-contiguous arrays.

Changes

  • Enhanced docstring for _hash_numpy_array: Documents that tobytes(order="C") may copy data for non-contiguous arrays (transposed, sliced views, Fortran-ordered) with performance implications for large arrays. Includes best practices in Notes section.

The behavior is correct and intentional—C-order normalization ensures deterministic hashes—but now explicitly documented for users working with large non-contiguous arrays.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: shaypal5 <917954+shaypal5@users.noreply.github.com>
Copilot AI changed the title [WIP] Update NumPy-aware hashing based on feedback Document tobytes() copy behavior in NumPy array hashing Feb 18, 2026
Copilot AI requested a review from shaypal5 February 18, 2026 17:21
@shaypal5 shaypal5 marked this pull request as ready for review February 18, 2026 17:29
@shaypal5 shaypal5 merged commit c33c6be into codex/add-test-and-benchmark-for-numpy-array-performance Feb 18, 2026
1 check passed
@shaypal5 shaypal5 deleted the copilot/sub-pr-337-again branch February 18, 2026 17:29
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