b = bytearray(
    '\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff')
larray = []
for i in range(0, len(b), 8):
    larray.append(struct.unpack('@q', b[i:i + 8])[0])
print(larray)
larray[1] = 1000
b = bytearray()
for l in larray:
    b += struct.pack('@q', l)
print(b)
Interpreting a bytearray as array of longs in Python 2.7