-
-
Notifications
You must be signed in to change notification settings - Fork 80
Mpy updates #397
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Mpy updates #397
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dlech
reviewed
Oct 9, 2025
bricks/_common/mpconfigport.h
Outdated
| #define MICROPY_PY_RANDOM_EXTRA_FUNCS (PYBRICKS_OPT_EXTRA_LEVEL1) | ||
| #define MICROPY_PY_RANDOM_SEED_INIT_FUNC ({ extern uint32_t pbdrv_clock_get_us(void); pbdrv_clock_get_us(); }) | ||
| #define MICROPY_MODULE_BUILTIN_INIT (1) | ||
| #define MICROPY_MODULE_BUILTIN_INIT (0) |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| #define MICROPY_MODULE_BUILTIN_INIT (0) | |
| #define MICROPY_MODULE_BUILTIN_INIT (MICROPY_PY_RANDOM) |
AFAICT, we still need this to seed the random module on hubs that support it.
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you!
…l hubs. This is only used in the random module. The color module says it uses it, but this is not the case.
Default to running the first `mpy` file instead of searching for __main__ in the metadata. Now hosts can specify the actual file name so we can include it in on-brick UIs like on EV3. This is distinct from __name__ = "__main__" which will still work, just as it does in normal Python. See pybricks/support#2364
bricks/_common/micropython: Share mpy execution. - Replaces `do_execute_raw_code` (which came from MicroPython but was changed upstream) with `do_execute_proto_fun` so we don't fall too far behind. - Create shared implementation that main and imported modules can both use to deduplicate code.
b5d1583 to
f72f846
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
bricks/_common/micropython: Share mpy execution.
Replaces
do_execute_raw_code(which came from MicroPython but was changedupstream) with
do_execute_proto_funso we don't fall too far behind.Create shared implementation that main and imported modules can both use
to deduplicate code.
bricks/_common/micropython: Run first mpy instead of main
Default to running the first mpy file instead of searching for main in
the metadata. Now hosts can specify the actual file name so we can include
it in on-brick UIs like on EV3.
This is distinct from
__name__ == "__main__"which will still work, just as itdoes in normal Python.
See pybricks/support#2364
bricks/_common/mpconfigport: Drop MICROPY_MODULE_BUILTIN_INIT.
This isn't used anywhere. The color module says it uses it, but this is not the case.