This is a noob question on Python.
Is there a way in Python to truncate off few bytes from the begining of bytearray and achieve this without copying the content to another memory location? Following is what I am doing:
inbuffer = bytearray()
inbuffer.extend(someincomingbytedata)
x = inbuffer[0:10]
del inbuffer[0:10]
I need to retain the truncated bytes (referenced by x) and perform some operation on it.
will x point to the same memory location as inbuffer[0] or will the 3rd line in the above code make a copy of data. Also, if the copy is not made, will deleting in the last line also delete the data referenced by x? Since x is still referencing that data, GC should not be reclaiming it. Is that right?
Edit:
If this is not the right way to truncate a byte buffer and return the truncated bytes without copying, is there any other type that supports such operation safely?