In Python, I am aware certain methods exist in python 3 that can create a new integer from an existing byte array. However, I am looking for a way to create a reference to a byte array, as an integer. Such that, if the reference is changed, then the underlying byte array is also changed.
In C, this would be done like the following:
int main(void) {
unsigned char bytes[4] = {1, 0, 0, 0};
int* int_ref = (int*)bytes;
*int_ref += 59;
printf("bytes is now %u %u %u %u\n",
bytes[0],
bytes[1],
bytes[2],
bytes[3]);
return 0;
}
The above program prints 60
. I am looking for a way to do this in Python.