Skip to content

fix: consistent byteorder settings#3954

Merged
ikrommyd merged 2 commits into
scikit-hep:mainfrom
ikrommyd:to-buffers-byteorder
Apr 7, 2026
Merged

fix: consistent byteorder settings#3954
ikrommyd merged 2 commits into
scikit-hep:mainfrom
ikrommyd:to-buffers-byteorder

Conversation

@ikrommyd

@ikrommyd ikrommyd commented Apr 7, 2026

Copy link
Copy Markdown
Member

Making a few changes to have consistent byteorder settings in the codebase.

First of all, ak.to_buffers defaults to native byteorder here:

byteorder=ak._util.native_byteorder,

We do the same for ak._do.to_buffers (which is used inside ak.to_buffers) for consistency even though it's semi-public API.

Secondly, buffers are generally native (always or almost always) as they are in-memory. Therefore ak.to_buffers should have the same defaults as ak.to_buffers. ak.from_buffers(*ak.to_buffers(...)) should just work on all systems. One shouldn't have to specify ak.from_buffers(*ak.to_buffers(...), byteorder=ak._util.native_byteorder) in order for this to work on a big-endian system for example.

And finally, awkward expects arrays/dtypes to be in native byteorder when the NumpyArray and Index classes are constructed as wrappers around the buffers. We modify the naming in the tests to express just that as the default in awkward internally is not "little". It's "native".

All of these changes are no-ops for little endian systems as ak._util.native_byteorder is "<". But they make byteorder settings more self-consistent in the codebase and make these ops that depend on byteorder seamless in big endian systems without one having to specify byteorder=">" explicitly just because they are on a different system.

@ikrommyd
ikrommyd requested a review from ariostas April 7, 2026 08:52
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3954

@codecov

codecov Bot commented Apr 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.25%. Comparing base (8640184) to head (2594039).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/_do.py 84.70% <ø> (ø)
src/awkward/operations/ak_from_buffers.py 94.44% <ø> (ø)

... and 9 files with indirect coverage changes

@ariostas ariostas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you, @ikrommyd!

@ikrommyd
ikrommyd merged commit e04256f into scikit-hep:main Apr 7, 2026
41 checks passed
@ikrommyd
ikrommyd deleted the to-buffers-byteorder branch April 7, 2026 18:03
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