1 | initial version |
Those two functions don't really do the same thing. They both return [0,0,0], so if that's all you want you could do:
def test3():
return [0,0,0]
The function test1 is probably slower because it has to actually construct an object to iterate over those values, while test2 does not. It might be more fair to compare functions that return all the values.