I am trying create a large list of numbers .
a = '1 1 1 2 2 0 0 1 1 1 1 9 9 0 0' (it goes over a ten million).
I've tried these methods:
%timeit l = list(map(int, a.split()))it was4.07 µs per loop%timeit l = a.split(' ')this was462 ns per loop%timeit l = [i for i in a.split()]it took1.19 µs per loop
I understand that the 2nd and 3rd variants are character lists whereas first is an integer list, this is fine. But as the number of elements gets to over ten million, it can take up to 6 seconds to create a list. This is too long for my purposes. Could someone tell me a more faster and efficient way to do this.
Thanks