From experience using %d
or %s
when formatting an integer in python 2 and 3 gives the same result. On top of that, it seems that using %s
instead of %d
when formatting an integer is a few nanoseconds faster.
Why should I ever use %d
when formatting an integer since it seems to have absolutely no effect on the final result?
In [8]: "foo %s bar" % 1000
Out[8]: 'foo 1000 bar'
In [9]: "foo %d bar" % 1000
Out[9]: 'foo 1000 bar'