-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
py/obj.h: Add m_new_obj_with_type macro. #8576
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
450e986
to
1114a6c
Compare
Codecov Report
@@ Coverage Diff @@
## master #8576 +/- ##
==========================================
- Coverage 98.23% 98.22% -0.01%
==========================================
Files 154 154
Lines 20364 20311 -53
==========================================
- Hits 20004 19951 -53
Misses 360 360
Continue to review full report at Codecov.
|
please rebase on latest master to pick up new renesas-ra port, which has 7 uses of |
Done. Not all 7 were suitable (two in timer.c immediately memset, and in mpthreadport.c it isn't actually an object). |
The first commit includes changes to In the second commit some cc3200 HAL files are unnecessarily changed (maybe line endings?). |
This is to replace the following: mp_foo_obj_t *self = m_new_obj(mp_foo_obj_t); self->base.type = &mp_type_foo; with: mp_foo_obj_t *self = mp_obj_malloc(mp_foo_obj_t, &mp_type_foo); Calling the function is less code than inlining setting the type everywhere, adds up to ~100 bytes on PYBV11. It also helps to avoid an easy mistake of forgetting to set the type. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This replaces occurences of foo_t *foo = m_new_obj(foo_t); foo->base.type = &foo_type; with foo_t *foo = mp_obj_malloc(foo_t, &foo_type); Excludes any places where base is a sub-field or when new0/memset is used. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Done. |
* Changes introduced in micropython#8576 missed changing this call to mp_obj_malloc.
This makes use of mp_obj_malloc() in more places to reduce binary size. Also see micropython#8576. Signed-off-by: David Lechner <david@pybricks.com>
This is to replace the following:
with:
Calling the function is less code than inlining setting the type everywhere, adds up to 100 bytes on PYBV11. Small, but every byte counts, right? :p
It also helps to avoid an easy mistake of forgetting to set the type.
Perf impact is negligible, possibly even improved? I specifically excluded
mp_obj_new_float
from using this (otherwise there was about a 1% decrease across the fp-heavy tests).