Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.6k
py/binary: Reorganize and refactor definitions for typecode letters.#18590
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
AJMansfield wants to merge4 commits intomicropython:masterChoose a base branch fromAJMansfield:typecodes
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+198 −165
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
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Also moving it from objarray.h to binary.h.Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
Code size report: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@## master #18590 +/- ##==========================================- 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. 🚀 New features to boost your workflow:
|
Sign up for freeto 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.
Uh oh!
There was an error while loading.Please reload this page.
Summary
This PR collects together all of the macro constants associated with the "typecode" value used across several different modules to encode information about the type identity of an associated pointer or memory buffer. These values were previously scattered across the codebase, often leading to confusion about the C API, resulting in e.g. defective memoryview objects with no typecode except for the read-write flag.
With this change:
MP_TYPECODE_C(custom_typedefed_int_t)would automatically pick the appropriate typecode letter at compile time thanks to the semantics of_Generic.'q'means, but it's still a lot easier to spot if you instead write it like:Testing
I've run the test suite across unix and rp2 on my own hardware. All extant tests pass; though as a pure refactor, this change can't be checked directly.
Some of the changes touch port-specific code for devices I don't have access to; hopefully CI will catch anything aggressively defective, but this ought to be tested on those other devices.
Trade-offs and Alternatives
Using
_Genericlimits compatibility to C11 and above. If that's a problem, potentially separate macros for each type could be declared instead --- but that's only marginally useful than single-letter typecodes.Potentially, it would be better to use the stdint names for the typecodes, i.e.
uint8_tinstead ofunsigned char; and in several of the places I've refactored there might be a more semantic typename to use as the argument --- the actual typename of the associated buffer, or perhaps even atypeofexpression involving that buffer.