Tkinter canvas create_image and create_oval optimization Tkinter canvas create_image and create_oval optimization tkinter tkinter

Tkinter canvas create_image and create_oval optimization


The canvas has performance problems when many items are created (more specifically, when new object ids are created). Deleting objects doesn't help, the problem is in the ever increasing object ids which are never reused. This problem usually doesn't appear until you have 10's of thousands of items. If you're creating 256/second, you'll start to bump into that problem in just a minute or two.

You can completely eliminate this overhead if you create 128 objects off screen once, and then simply move them around rather than destroying and recreating them.