Why it is faster to return a tuple than multiple values in Python?
<p>I did a small test:</p>

<pre><code>In [12]: def test1():
    ...:     return 1,2,3
    ...: 

In [13]: def test2():
    ...:     return (1,2,3)
    ...: 

In [14]: %timeit a,b,c = test1()
</code></pre>

<p>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</p>

<pre><code>In [15]: %timeit a,b,c = test2()
</code></pre>

<p>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</p>

<p><strong>Returning a tuple is about 15% faster than returning multiple values. Why is it so?</strong></p>

<p>Both <code>test1</code> and <code>test2</code> results in same bytecode, so they have to perform in same speed. Your measurement conditions wasn't consistent (e.g. CPU load was increased for test2, due to additional background processes).</p>

<pre><code>&gt;&gt;&gt; import dis
&gt;&gt;&gt; def test1():
...     return 1,2,3
...
&gt;&gt;&gt; def test2():
...     return (1,2,3)
...
&gt;&gt;&gt; dis.dis(test1)
  2           0 LOAD_CONST               4 ((1, 2, 3))
              3 RETURN_VALUE
&gt;&gt;&gt; dis.dis(test2)
  2           0 LOAD_CONST               4 ((1, 2, 3))
              3 RETURN_VALUE
&gt;&gt;&gt;
</code></pre>

python performance tuples return-value benchmarking