pythonturtle-graphicsprocessing-efficiency

Is setting `turtle.speed(0)` necessary when we have turtle.tracer(0)


Is there a difference between:

import turtle
turtle.tracer(0)
turtle.speed(0)
while True:
    turtle.goto(turtle.xcor()+1)
    turtle.update()

And:

import turtle
turtle.tracer(0)
while True:
    turtle.goto(turtle.xcor()+1)
    turtle.update()

I've heard that setting turtle.speed(0) make things faster, but if so, I don't see any difference.


Solution

  • According to: https://www.eg.bucknell.edu/~hyde/Python3/TurtleDirections.html

    The tracer() method:

    And the official documentation https://docs.python.org/2/library/turtle.html#turtle.speed says:

    CONCLUSION: I think it is fair to say that:

    If you are doing very complex graphics, and you want speed, use both and in complex graphics you should see some sort of difference as they both speed up the turtle

    If you are doing simple graphics, the speed from using both will not as noticeable than if you did a complex one, so it would not be necessary to use both but only use, for example: turtle.speed(0) As according to the official documentation: https://docs.python.org/2/library/turtle.html#turtle.tracer tracer() has been deprecated in newer versions of the turtle module.

    So I would suggest changing the speed first, and then if you need faster performance change the tracer. Or you can just disable the tracer because you do not want the turtle animation to show, really it is up to you, but I hope I could have guided you.