turtles slowing down

Lee Harr missive at hotmail.com
Thu Jul 21 21:43:34 EDT 2011


>  there
> was a steady slowing down of turtles as time goes

The problem is that when the turtle "draws" it does not
just put marks on the canvas, it actually creates new
canvas items.

Canvas items aren't just pixels on the canvas, they are
full-fledged objects which (if you wanted to) you could
get a handle on and move around on the canvas, raise
up above other items, change the color of, etc.

Even if you are just drawing back and forth over the
same line repeatedly, each time you go fd() with the
pen down you are making more and more items on
the canvas. It needs to keep track of those, and that
is what slows it down.

Try adding b1.penup() right after creating the Ball
and you will see your times will remain constant.


I have the same situation in pynguin, the turtle graphics
application that I maintain (pynguin.googlecode.com)

One of my todo items is to make it so that occasionally
those canvas items get painted down on to the canvas
and then deleted.

Having the items around is useful (it makes undo much
easier, for instance) but the slowdown on long-running
programs is a definite problem.

 		 	   		  



More information about the Python-list mailing list