Number of rects is not very important. 

The total area is much more important. Also, aligning surface widths to 
multiples of 16 and blitting to locations on the x axis that are multiples of 
16 can help the performance of the blitting. (I just learned that from this 
mailing list.) Setting the source surface's RLEACCEL flag helps if there is a 
lot of solid coloration in your source surface.

This script reduces the update area as much as possible:
  https://bitbucket.org/jmm0/optimize_dirty_rects/downloads

Jason



From:Abhas Bhattacharya <abhasbhattachar...@gmail.com>
To: pygame-mirror-on-google-gro...@googlegroups.com 
Sent: Saturday, June 14, 2014 8:13 PM
Subject: [pygame] Perf - No. of rects vs area of rects
 


Does the performance of pygame.update depend solely on no. of rects or total 
area of all rects passed to it?
I was thinking of a small speedup by splitting two intersecting rects into 
three non-intersecting rects, which will reduce the toal area, but increase the 
no. of rects.
Its probably a very small gain, and might result in a actual loss if the no. of 
rects explode. But if I know for sure that performance depende solely on one 
factor or the other, small gains like h=this might be possible.

Reply via email to