According to IPython's %timeit
function, map
is a bit faster:
In [16]: s = ' '.join(map(str, range(1000)))
In [17]: %timeit [int(c) for c in s.split()]
10000 loops, best of 3: 171 µs per loop
In [18]: %timeit list(map(int, s.split()))
10000 loops, best of 3: 138 µs per loop
Tested with IPython 1.2.1 and Python 3.4.3 and with different input sizes (range(1000)
, range(10)
, and range(100000)
).
Of course, the interesting question is: Is this part of the code slowing down your program (assuming that that's why you are asking, and not out of pure curiosity). Compared to, e.g., reading the input
(from a file, I presume?), or doing calculations with the data, it might be pretty insignificant.