I did a small test:
In [12]: def test1():
...: return 1,2,3
...:
In [13]: def test2():
...: return (1,2,3)
...:
In [14]: %timeit a,b,c = test1()
The slowest run took 66.88 times longer than the fastest. This could mean that an intermediate result is being cached. 10000000 loops, best of 3: 92.7 ns per loop
In [15]: %timeit a,b,c = test2()
The slowest run took 74.43 times longer than the fastest. This could mean that an intermediate result is being cached. 10000000 loops, best of 3: 80.1 ns per loop
Returning a tuple is about 15% faster than returning multiple values. Why is it so?
test1andtest2are equivalent in terms of bytecode