-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Feature] OrderedDict.move_to_end
#8234
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
Conversation
Unfortunately, this change is overflowing the available flash size on a few builds :-/ there's no easy solution for this, the resolution may be to choose not to include it, or to disable some other feature on the failing board. |
Yeah, should i add a new #define + #ifdef to control whether the API's code gets added? Could also add the method to dict's table, but this breaks worse than fixes:
|
Yup. We use Instead of making yet another flag, there is a kitchen-sink one called However, the boards that are overflowing I don't think would be fixed by that. We need to look at the SAMD51 boards that are close to overflowing and come up with a general strategy to shrink them. @jepler started to do this for some other boards. For instance, we may be able to shrink |
No worries, we're not in a rush :D Will add the new Let me know if any code should be re-written for readability/matching codestyle of the repo |
EDIT: Should be good to go now. |
Could you add some tests to |
Here are the test failure details:
Looks like it changed from printing See https://github.com/adafruit/circuitpython/actions/runs/5744164923/job/15569982403?pr=8234, and then click "Print failure info" to see the details I pasted above. |
Should i have that many tests, for every combination of positional and keyword usage (made that to confirm i made things correctly), or would it be better to just check moving either way? |
I think the main thing is to test the moving and edge cases (e.g. on an empty dict, key not found, etc.) not so much the arg parsing. It doesn't hurt but the testing is more about the functionality than the arg parsing. Also test arg validation maybe: suppose you pass a non-bool for the bool arg. |
Tests are now checking (all?) edge cases + are successful, however flash is still too large... |
this implementation is hoped to be smaller. (feather_m4_express/fr fits unlike the other PR; approximate savings ~600 bytes) Minor difference to standard Python: A `dict` object has a `move_to_end` method. However, calling this method always results in TypeError. Implementing it this way means that the method table can still be shared between OrderedDict and builtin dict. Closes adafruit#4408.
this implementation is hoped to be smaller. (feather_m4_express/fr fits unlike the other PR; approximate savings ~600 bytes) Minor difference to standard Python: A `dict` object has a `move_to_end` method. However, calling this method always results in TypeError. Implementing it this way means that the method table can still be shared between OrderedDict and builtin dict. Closes adafruit#4408.
I wrote #8258 which also implements move_to_end, but at smaller flash cost. Thank you for the original implementation! |
OrderedDict.move_to_end: alternate implementation of #8234
Closed in favor of #8258. |
Closes #4408
Adds the method in the title. First time i write a C-Python binding, please let me know if anything should be changed
My little test: