|
|
|
|
|
by Ysx
2847 days ago
|
|
Red herring perhaps - seems due to the inplace add. It's quicker yet if you take out the multiple assigment: $ for STMT in "a2, c = a2+c, c+2" "a2 += c; c += 2" "a2 = a2+c; c = c+2"; do
echo \[$(python3 -m timeit "a2 = 1; c = 1; $STMT")\] $STMT
done | sort -n
[... 0.0547 usec per loop] a2 = a2+c; c = c+2
[... 0.0569 usec per loop] a2, c = a2+c, c+2
[... 0.0608 usec per loop] a2 += c; c += 2
|
|
But definitely it seemed that python2 and python3 had significantly different performance.