Skip to content

Conversation

@andrewleech
Copy link
Contributor

The macro & helper pair mp_obj_malloc & mp_obj_malloc_var is already present for use when creating a new object and setting its base.type immediately.

This PR introduces matching mp_obj_malloc_with_finaliser & mp_obj_malloc_var_with_finaliser helpers to use in the same way for classes that need a finaliser (ie automatic running of __del__ when the object is garbase collected).

Andrew Leech added 2 commits February 16, 2024 15:53
Also matching mp_obj_malloc_var_with_finaliser.

These can be used like the mp_obj_malloc{,_var} macros
for situations where a finaliser is needed.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Replace usages of m_new_obj_with_finaliser() with separate
type setting with the mp_obj_malloc_with_finaliser helper.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
@andrewleech andrewleech added the py-core Relates to py/ directory in source label Feb 16, 2024
@codecov
Copy link

codecov bot commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (223e0d9) 98.36% compared to head (89aa3b3) 98.36%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13685      +/-   ##
==========================================
- Coverage   98.36%   98.36%   -0.01%     
==========================================
  Files         159      159              
  Lines       21069    21065       -4     
==========================================
- Hits        20724    20720       -4     
  Misses        345      345              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +8 +0.001% standard
      stm32:    +4 +0.001% PYBV10
     mimxrt:    +8 +0.002% TEENSY40
        rp2:    -8 -0.002% RPI_PICO
       samd:    +4 +0.002% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@andrewleech
Copy link
Contributor Author

Duplicate of #13682

@andrewleech andrewleech marked this as a duplicate of #13682 Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py-core Relates to py/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant