As part of our efforts of making PyPy's Python interpreter usable we put quite some effort into interfacing with external libraries. We were able, in quite a short amount of time (I think beginning really from Leysin sprint, or slightly earlier) to provide a prototype of the ctypes library. It is written in completely normal Python, at applevel, based on a very thin wrapper around the libffi library. This makes development a lot easier, but it makes the resulting ctypes implementation rather slow. The implementation is not complete yet and it will still need quite some effort to make it feature-complete (ctypes has lots of details and special cases and
do-what-I-mean magic). Yet another point will be to make it faster, but that's for much later.
The implementation is good enough to run those parts of Pyglet that don't depend on PIL (which PyPy doesn't have). Here are a few pictures of running Pyglet demos on top of compiled pypy-c.
To compile a version of PyPy that supports ctypes, use this highly sophisticated command line
./translate.py --gc=generation ./targetpypystandalone.py --allworkingmodules --withmod-_rawffi
Note: this works on linux only right now.
The list of missing small ctypes features is quite extensive, but I consider the current implementation to be usable for most common cases. I would love to hear about libraries written in pure python (using ctypes), to run them on top of PyPy and use them as test cases. If someone knows such library, please provide a link.
Wednesday, February 20, 2008
Running Pyglet on PyPy
As part of our efforts of making PyPy's Python interpreter usable we put quite some effort into interfacing with external libraries. We were able, in quite a short amount of time (I think beginning really from Leysin sprint, or slightly earlier) to provide a prototype of the ctypes library. It is written in completely normal Python, at applevel, based on a very thin wrapper around the libffi library. This makes development a lot easier, but it makes the resulting ctypes implementation rather slow. The implementation is not complete yet and it will still need quite some effort to make it feature-complete (ctypes has lots of details and special cases and
do-what-I-mean magic). Yet another point will be to make it faster, but that's for much later.
The implementation is good enough to run those parts of Pyglet that don't depend on PIL (which PyPy doesn't have). Here are a few pictures of running Pyglet demos on top of compiled pypy-c. To compile a version of PyPy that supports ctypes, use this highly sophisticated command line
./translate.py --gc=generation ./targetpypystandalone.py --allworkingmodules --withmod-_rawffi
Note: this works on linux only right now.
The list of missing small ctypes features is quite extensive, but I consider the current implementation to be usable for most common cases. I would love to hear about libraries written in pure python (using ctypes), to run them on top of PyPy and use them as test cases. If someone knows such library, please provide a link.
The implementation is good enough to run those parts of Pyglet that don't depend on PIL (which PyPy doesn't have). Here are a few pictures of running Pyglet demos on top of compiled pypy-c. To compile a version of PyPy that supports ctypes, use this highly sophisticated command line
./translate.py --gc=generation ./targetpypystandalone.py --allworkingmodules --withmod-_rawffi
Note: this works on linux only right now.
The list of missing small ctypes features is quite extensive, but I consider the current implementation to be usable for most common cases. I would love to hear about libraries written in pure python (using ctypes), to run them on top of PyPy and use them as test cases. If someone knows such library, please provide a link.
Running Pyglet on PyPy
Subscribe to:
Post Comments (Atom)
9 comments:
This is very cool news indeed! The second screenshot seems to show a strange artefact though on the inside of the torus. Is that running the unmodified examples/opengl.py code, or has the example been modified to display a second torus? It should also be noted that pyglet is perfectly usable without PIL (as long as you have libgdk installed under Linux which almost everyone will do).
ps. it's "pyglet" with a little "p" :)
Very cool :)
Here's two more ctypes things... which you probably know about already, but eh :)
http://pyopengl.sf.net/
http://www.pygame.org/ctypes/
cu,
Congratulations from me!
hi illume,
yep, we know about those, thank you anyway :-).
Cheers,
Carl Friedrich
Very exciting to see my humble 'triangles' pyglet demo being used in the blue colored screenshot. If anyone's interested, the code for that is here: http://tartley.com/?p=264
I should remember to put an explicit CC license on my whole site.
http://utidylib.berlios.de/
needs only ctypes, iirc.
Please try the ctypes-based pysqlite reimplementation at http://hg.ghaering.de/pysqlite3/
It's meant to become the "sqlite3" module for PyPy.
Hi Gerhard,
yip, we know about this sqlite implementation, thank you! We are already using it for our tests (and most of its tests already work).
Cheers,
Carl Friedrich
Post a Comment