How to know which is more advatageous with assigning same value to different attributes in python
<p>Between the two in python which will be faster and advatageous</p>

<pre><code>a = b = c = d = 1
</code></pre>

<p>and</p>

<pre><code>a = 1
b = 1
c = 1
d = 1
</code></pre>

<p>Simply run a test:</p>

<pre><code>&gt;&gt;&gt; import timeit
&gt;&gt;&gt; min(timeit.repeat('a = b = c = d = 1', number=10000000))
0.4885740280151367
&gt;&gt;&gt; min(timeit.repeat('a = 1; b = 1; c = 1; d = 1', number=10000000))
0.6283371448516846
</code></pre>

<p>Also note:</p>

<pre><code>&gt;&gt;&gt; min(timeit.repeat('a, b, c, d = 1, 1, 1, 1', number=10000000))
0.4040501117706299
</code></pre>

python python-2.7