if __name__ == '__main__':
    a = array('i')
a.extend(list(range(0, 1000000)))
filename = 'a_million_ints.dat'
WriteInts(a, filename)
r = ReadInts(filename)
print('The 5th element is %d' % r[4])
Python list serialization - fastest method