one-liner for loop vs map function in python Which is better?

  map-function, one-liner, performance, python

I have tried both one-liner for loop and map function in python but I need to know which is better in terms of performance and time.
here is what I tried:
I created a list of tuples each holding two values and named it x and then I iterated over x via one-liner for loop and stored first value of each tuple in a then repeated the same process for b but this time instead of for loop I used map(). output is same but what about performance and which I should use more often?

x = [(1, 2), (3, 4), (5, 6)]

a = [y[0] for y in x]
output: a = [1, 3, 5]

b = list(map(lambda y: y[0], x))
output: b = [1, 3, 5]

Source: Python Questions

LEAVE A COMMENT