Is there any way to modify python list through slice with only one value without memory allocations?
Something like that:
b = range(10)
b[2:5] = 1
The problem here is that about memory. I do not want to allocate new objects, because I work with MicroPython on embedded system and unnecessary allocations will affect performance. So should I use cycle or there is more elegant way?
However, I am not really sure about how memory allocations work in python. I have read that Python is smart and allocates variables in stack as well as in heap depending on their usage. Therefore I can not say if:
b = range(10)
b[2:5] = [1]*3
will create a bit of a work for a garbage collector.