processing a byte array with constrained memory #14104
Replies: 2 comments 4 replies
-
It does not shrink the array. It creates a second one and copies the requested data over. So, at the moment there's only one clear path: Allocate the maximum needed right at the beginning and live with it. Use memoryviews to partition that array if desired. |
Beta Was this translation helpful? Give feedback.
-
I finally managed to shrink this 20k bytearray, without using any extra memory, via assignment slicing. Grateful for all the hand holding, Jimmo in particular. My only gripe is locating the bytes to remove is hard work without .find & .replace, but I eventually worked out how to drag templates over the array to find the bytes that needed to go. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
At first glance
seems a good way to shrink a bytearray.
But if we constrain the memory
it shows that to shrink an array I need free memory a bit bigger than the array.
I can use memoryview to alter bytes in the array without getting an 'allocation failed' but I can't figure out a way to resize with it. Any thoughts on how I might selectively remove bytes from a 20k byte array without needing ~21k of ram to do it?
Beta Was this translation helpful? Give feedback.
All reactions