I was working on a Python turtle graphics project with my students where we were creating a complex fractal pattern. The issue was, the drawing was painfully slow, with the turtle visibly crawling across the screen for each line segment.
The solution? Python’s turtle.tracer() function. This useful but often overlooked feature can dramatically improve the performance of your turtle graphics.
In this article, I’ll cover several ways you can use the tracer function to control animation speed in Python Turtle (along with some practical examples).
What is Turtle Tracer in Python?
The tracer() function in Python’s turtle module gives you control over the animation of the turtle’s movements. It essentially lets you decide whether to show the animation in real-time or to turn it off and only display the final result.
This becomes incredibly useful when:
- You’re creating complex drawings with many steps
- You need to generate graphics quickly without waiting for animations
- You want to control the update speed of your turtle graphics
Method 1: Basic Tracer Usage
The easy way to use the tracer function is to simply turn animation on or off.
import turtle
# Create a screen and turtle
screen = turtle.Screen()
t = turtle.Turtle()
# Turn off the animation
screen.tracer(0)
# Draw a complex shape (a star)
for _ in range(36):
t.forward(100)
t.right(170)
# Update the screen to show the final result
screen.update()
# Keep the window open
turtle.done()You can refer to the screenshot below to see the output.

In the above code, I’ve set screen.tracer(0) which turns off animation completely. After drawing the entire star, I use screen.update() to refresh the screen and show the final result.
This method makes the drawing appear instantly, which is perfect for complex shapes!
Method 2: Control Animation Speed
Sometimes you might want to show the animation but at a controlled rate. The tracer function allows for this too:
import turtle
screen = turtle.Screen()
t = turtle.Turtle()
# Set animation delay (first argument is update frequency, second is delay)
screen.tracer(1, 10)
# Draw a square spiral
for i in range(100):
t.forward(i)
t.right(90)
turtle.done()You can refer to the screenshot below to see the output.

In this example, I’ve used screen.tracer(1, 10) where:
- The first argument (1) means update after each turtle action
- The second argument (10) specifies a delay of 10 milliseconds
This creates a nice balanced animation that’s not too slow but still visible to the user.
Check out Python Turtle Get Position
Method 3: Selective Updates for Complex Drawings
For really complex drawings, you might want to update the screen only at certain points:
import turtle
screen = turtle.Screen()
t = turtle.Turtle()
t.speed(0) # Set turtle speed to fastest
# Turn off animation
screen.tracer(0)
# Draw a complex mandala pattern
for i in range(180):
t.forward(100)
t.right(30)
t.forward(20)
t.left(60)
t.forward(50)
t.right(30)
t.penup()
t.setposition(0, 0)
t.pendown()
t.right(2)
# Update every 10 iterations to show progress
if i % 10 == 0:
screen.update()
# Final update to ensure everything is displayed
screen.update()
turtle.done()You can refer to the screenshot below to see the output.

In this example, I’ve created a pattern where I only update the display every 10 iterations. This gives a nice balance between speed and being able to see the progress of your drawing.
Method 4: Use Tracer with Multiple Turtles
When working with multiple turtles, tracer becomes even more valuable:
import turtle
import random
# Set up the screen
screen = turtle.Screen()
screen.bgcolor("black")
# Turn off animation completely
screen.tracer(0)
# Create multiple turtles
turtles = []
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
for i in range(6):
t = turtle.Turtle()
t.color(colors[i])
t.penup()
t.hideturtle()
t.speed(0)
turtles.append(t)
# Position turtles at different starting points
for i, t in enumerate(turtles):
t.goto(-250 + i*100, 0)
t.pendown()
t.showturtle()
# Simulate a race with periodic updates
for _ in range(100):
# Move each turtle a random distance
for t in turtles:
t.forward(random.randint(1, 5))
# Update the screen every iteration to see the race progress
screen.update()
turtle.done()This creates a fun turtle race where all the turtles move simultaneously, and the screen updates after each round of movements.
Read Make a Smiling Face in Python Turtle
Method 5: Control Tracer Dynamically
You can also change the tracer settings during program execution:
import turtle
import time
screen = turtle.Screen()
t = turtle.Turtle()
# Start with animation on
screen.tracer(1)
# Draw a triangle with animation visible
for _ in range(3):
t.forward(100)
t.left(120)
# Pause to see the result
time.sleep(1)
# Turn off animation for the complex part
screen.tracer(0)
t.penup()
t.goto(-150, 0)
t.pendown()
# Draw a complex shape without animation
for i in range(36):
t.forward(100)
t.right(170)
# Show the final result
screen.update()
turtle.done()This approach lets you have the best of both worlds: animations for simple parts and instant results for complex parts.
Check out Python Turtle Nested Loop
Troubleshoot Common Tracer Issues
Now, I will explain how to troubleshoot common issues that occur while working with tracer.
Issue 1: Nothing Appears on Screen
If you’ve turned off the tracer with screen.tracer(0) but don’t see anything on screen, you probably forgot to call screen.update(). Always remember to update the screen when you want to display your results.
Issue 2: Program Seems Frozen
When working with very complex drawings and tracer turned off, your program might appear frozen. Add occasional screen.update() calls as I showed in Method 3, to provide visual feedback.
Issue 3: Animation Speed Issues
If your animation is still too slow, even with tracer adjustments, consider:
- Using the turtle’s
speed(0)setting for maximum turtle speed - Simplifying your drawing
- Using
penup()andpendown()strategically to avoid drawing unnecessary lines
Python Turtle Tracer vs. Turtle Speed
It’s important to understand the difference between the turtle’s speed() method and the tracer() function:
turtle.speed()controls how fast an individual turtle movesscreen.tracer()controls whether movements are animated at all and how frequently the screen updates
For optimal performance in complex drawings, use both: set speed(0) for maximum turtle speed and control animation with tracer().
The Python Turtle tracer function is an essential tool for anyone creating complex graphics with the turtle module. It allows you to balance between seeing the drawing process and getting quick results.
Other Python Turtle articles you may also like:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.