-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enable MICROPY_PY_ARRAY_SLICE_ASSIGN on SAMD21 #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Turning on |
I just noticed that this feature was missing on the non-express builds as I tried migrating some code to a smaller board. I'd love to see it there. If ultimately not, would it be possible to update the error message? Currently it was something along the lines of The workaround for a common case is a (presumably slow) manual loop: Before: a[start:end] = data After: # Assuming len(data) == end-start.
# Does not deal with expanding bytearray a if end-start would go beyond its bounds.
k = start
for b in data:
a[k] = b
k += 1 If you could even support just the case of slice assignment into a preallocated fixed buffer without reallocation/resizing that would be fine for my use case (I generally try to avoid reallocs) |
This costs 376 bytes on a Trinket M0 leaving 33412 bytes free. Fixes #193
The following code:
works just fine on MicroPython and CircuitPython on the ESP8266, but fails with
TypeError: 'bytearray' object does not support item assignment
on the M0 boards. This is the fastest way to copy a fragment of a byte array (since it uses memcpy in C), but since it doesn't work consistently on all ports, I can't use it in my libraries. It would be nice if all ports supported it.
The text was updated successfully, but these errors were encountered: