4 Respuestas
+ 32
not really sure why you need the speed of a print statement, but I would bet on the first one as the second and third need to do some string operations before passing a single value to print. However that guess relies on the assumption that print itself has a clever way of handling multiple arguments 😀. If you need to know for sure put each print in a loop with few thousand iterations and time the loops to get an average as single statements performance can vary depending on your system state at the moment of execution.
+ 7
Nikolay Nachev does python have a concept of flushing the output to stdout somewhat independently of the actual print statement as in C? Perhaps not as python is generally interpreted?
+ 5
by taking the tests,
1st-{0} is not equal to {1}
2nd-a+"is not equal to"+b
3rd-a,"is not equal to", b
https://code.sololearn.com/c1X5F388kjT7/?ref=app
https://code.sololearn.com/cuO6u32EpU4l/?ref=app
https://code.sololearn.com/cFOguxjbZ01j/?ref=app
+ 1
Check out Python3 string templates for top preformance