[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] speculation: a JIT for Pygame



The problem:

Unlike other image packages, Pygame supports operations on many different pixel formats: 32 bit pixel with alpha can blit to 24 bit without alpha, eight bit palette can blit to 16 bit without alpha, and so on. This makes it cumbersome to add new blit operations, like exclusive-or, and even more difficult to add a new pixel format.

The proposal:

With the acceptance of PEP 3146 the Unladen Swallow offshoot of CPython will be merged back into trunk Python sometime around Python 3.3. Unladen Swallow brings with it a Python JIT powered by LLVM. LLVM is a compiler tool kit that also provides runtime compilation to machine code. So the idea is to generate blitters on demand for various pixel configurations with LLVM.

Alternatives:

Another possibility is to design as generic a blitter loop as possible, then include some specialized loops for common pixel formats. Or one could develop a preprocessor that translates a specialized blit description language into corresponding C code, much the way Pyrex transforms Python like code into C. This approach is used to write sound modules for the Lisp based sound processing language Nyquist.


This is all just far out speculation. It is a long term goal not intended for the next Pygame release.

Lenard Lindstrom