p5
p5 copied to clipboard
very slow when drawing a large number of points in a draw() function
Describe the bug when trying to fill the canvas with pixels using a loop, the application is VERY slow.
To Reproduce
def draw():
for x in range(s):
for y in range(s):
fill(some_different_colors)
point(x, y)
in my case s = 20
also slow with circle and rect func
System information:
- p5 release (version number or latest commit): 000b562
- Python version: 3.7
- Operating system: kubuntu 19.04
update: same performance using
- p5 release (version number or latest commit): 0.6.0
- Python version: 3.8
- Operating system: manjaro
We've noticed this issue as well, and we'll try to address this over the summer.
Seeing similar sluggish performance in draw()
on a 2019 Macbook Pro.
First, I really enjoy p5. p5 is about 3 times as slow as Processing (python mode) when executing:
for k in range (len (circleList)): ellipse ( (200+2*k, circleList[k]), 5, 5)
where circleList is a list of 250 y coordinates. The code is executed on every frame.
I am using Python 3.8.2. The code is from "Math Adventures with Python", generating a sine wave from a small circle travelling on the circumference of a large circle. I also imported p5 using pypy3, but the execution time is the same. I am using a 4.5 GHz I6600k processor.
I have the same performance problem with the line function I use line to make a gradient on background, something like
for y in range(height):
stroke(y/height*255, 80,255*(1-y/height))
line(0,y,width,y)
not only is it slow, but the same code with p5.js in firefox (javascript in the not fastest browser for it) is three to four time more quick. openGl could theorically handle this very easely. Tens of thousands of polygons can normally be drawn in a second. Is vispy the problem ?
#293 will fix this