Closed dpgeorge closed 2 years ago
@dpgeorge Thanks! I see that my use of the heap is a bit sloppy and ad-hoc. I'll try to watch out for this in the future.
I did review all the memory allocations in ulab and these were the ones that could be eliminated.
Actually, now that you mention it, things like https://github.com/v923z/micropython-ulab/blob/2b4292abcc4f22acf242b2b4656a65cd124f1a5e/code/ndarray.c#L910 could be taken out, because ULAB_MAX_DIMS
is known at compile time. I don't see any reason for dynamically allocating the memory. N.B., my comment is not a hint at anything.
Yes, that does look like a temporary shape
array that can be allocated on the C stack.
OK, thanks for the confirmation! I'll try to weed these instances out.
This is a simple change to reduce the use of heap allocation in
optimize.bisect
,optimize.fmin
andoptimize.newton
.