You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
micropython-specific call to pre-allocate object to a given size #917
Here's the idea I had for a long time, remember at right time to record it: to fight memory fragmentation, etc. it would be nice to have call like:
obj = micropython.alloc(type, 10)
which would create a container object which could hold up to 10 items without reallocations. Obvious candidates for type are list and dict, and support for more types can be added as makes sense.
Note that we still can stay compatible with other Pythons by providing shim:
This is a neat idea. It would be pretty easy to implement, since dict and list already have C functions to preallocate. bytearray is not needed since its constructor already does this.
Activity
dpgeorge commentedon Oct 18, 2014
This is a neat idea. It would be pretty easy to implement, since dict and list already have C functions to preallocate. bytearray is not needed since its constructor already does this.
Merge pull request micropython#917 from dglaude/patch-1
dpgeorge commentedon Jun 24, 2022
Closing due to inactivity.