Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

py/misc: Add byte-swapping macros.#18542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
agatti wants to merge1 commit intomicropython:master
base:master
Choose a base branch
Loading
fromagatti:builtin-swaps

Conversation

@agatti
Copy link
Contributor

@agattiagatti commentedDec 10, 2025
edited
Loading

Summary

This PR adds byte-swapping macros for 16-, 32-, and 64-bit values.

Modern compilers are usually able to detect manual byte/endian swaps and will generate optimised code sequences if they know how to do that. However, in certain situations it may be helpful to let the compiler generate an optimised sequence if it doesn't recognise the pattern.

Most compilers provide built-in byte swap operations for 16, 32, and 64 bit values, accessed via "__builtin_bswap", but if those are not available a fallback implementation is provided.

This happens to shrink the ESP8266 port by a few bytes and speed AES-ECB operations up on that port by a tiny bit.

Testing

Besides the usual CI tests round, on an ESP8266EX the full test suite passes with the same number of errors as regular 1.27.0 master (PR to fix those coming up soon).

This commit adds byte-swapping macros for 16-, 32-, and 64-bit values.Modern compilers are usually able to detect manual byte/endian swaps andwill generate optimised code sequences if they know how to do that.However, in certain situations it may be helpful to let the compilergenerate an optimised sequence if it doesn't recognise the pattern.Most compilers provide built-in byte swap operations for 16, 32, and 64bit values, accessed via "__builtin_bswap<size>", but if those are notavailable a fallback implementation is provided.Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
@codecov
Copy link

codecovbot commentedDec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (3f796b6) to head (9dae150).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@##           master   #18542      +/-   ##==========================================- Coverage   98.38%   98.38%   -0.01%==========================================  Files         171      171                Lines       22301    22300       -1     ==========================================- Hits        21940    21939       -1  Misses        361      361

☔ 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.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

Code size report:

Reference:  all: Bump version to 1.27.0. [78ff170]Comparison: py/misc: Add byte-swapping macros. [merge of 9dae150]  mpy-cross:    +0 +0.000%    bare-arm:    +0 +0.000% minimal x86:    +0 +0.000%    unix x64:    +0 +0.000% standard      stm32:    +0 +0.000% PYBV10     mimxrt:    +0 +0.000% TEENSY40        rp2:    +0 +0.000% RPI_PICO_W       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS  qemu rv32:    +0 +0.000% VIRT_RV32

@dpgeorgedpgeorge added the py-coreRelates to py/ directory in source labelDec 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

py-coreRelates to py/ directory in source

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@agatti@dpgeorge

[8]ページ先頭

©2009-2025 Movatter.jp