- Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 5.3.0 on 2020-04-29; Adafruit CircuitPlayground Express with samd21g18
>>> import array
>>> big = array.array("B", [128] * 8000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
MemoryError: memory allocation failed, allocating 32000 bytes
I can workaround this with a hacky doubling method using the array itself:
- Code: Select all | TOGGLE FULL SIZE
>>> workaround = array.array("B", [0] * 1000)
>>> workaround.extend(workaround)
>>> workaround.extend(workaround)
>>> workaround.extend(workaround)
>>> len(workaround)
8000
Is there a better way to do that in Python / CircuitPython? It would be nice to be able to fill it with a specified value without allocating any memory for a same size data structure. ulab isn't an answer here as it's a CPX.
I've been playing around with a Talkie port and am currently using "B" arrays to keep memory usage low for RawSample.