Reducing pygame cpu-load to < 4 %

Bernardo Innocenti bernie at
Sun Dec 9 19:29:27 EST 2007

On 12/09/07 19:08, Noah Kantrowitz wrote:
> Unfortunately this is not possible in most games, as doing them purely
> vector-based is infeasible. A lot of the artwork made for games will be
> standard raster graphics, and will need to be designed for a specific
> screen. If there are changes in the future, they can always be redrawn.

The conversion to the screen format can happen at load
time, rather than each time the bitmap is being redrawn
on screen.

Doing it systematically is very easy:

  Surface *load_image(const char *filename)
      Surface *s = NULL, tmp;

      if ((tmp = IMG_Load(filename))
          s = SDL_DisplayFormat(tmp);
      return s;

Some libraries, notably SDL, make blitting graphics between
different pixel formats a little bit too transparent.
As a result, developers don't even notice and huge performance
bugs like this slip through.

 |___|   Bernardo Innocenti -
  \___\  One Laptop Per Child -

More information about the Devel mailing list