Showing posts with label pyglet. Show all posts
Showing posts with label pyglet. Show all posts

Tuesday, April 24, 2012

Ways to speed up yer Python code

So I've been looking into ways to get Python code to run quickly, which is a continuation of the search I did last year (yikes, it's been almost a year since this began...)

I spent time some getting Cython working, and getting the code to work with it, but I kept running into difficult-to-solve problems with Python data types in Numpy arrays. Particularly, an array that wouldn't compile because the compiler claimed it was of type long when I defined it as int, or at least as far as I can tell. I eventually decided to shelve that and look in other directions.

Currently, I'm changing the Pygame bits over to Pygame in order to make use of hardware acceleration, which is iffy under Pygame. This has the additional benefit of allowing the code to work under PyPy, the successor to Psyco. A drawback, however, is that pyglet wants to run the program's main event and draw loops itself. I've gotten in some more coding experience, so I'm less standoffish about that now than I was before, but to really do things the pyglet way everything has to be a sprite, or a polygon. The way we draw liquids at the moment in Pygame uses filled polygons, so it's good that there's a way to port this over. The combination of hardware acceleration and JIT compiling is a potent one, and could potentially bring better performance than even using Psyco... if only I could figure out how to install pyglet to a PyPy installation.

If this fails for some reason, there's still weave, a system for inlining C code in Python. My problems with C and C++ tend to concern linking; C itself I have no trouble with, but getting code more complex than a handful of simply-included source files to link together into an executable has been a woeful journey for me.

Anyway, work continues. You can't see it on your end, but behind the scenes of this blog's inscrutable periods of silence are me wringing my hands over the problems I've been facing. I have considered opening the source, or at least posting bits of it, and asking for advice from you guys. I don't suppose there are any Python mavens reading this?

Wednesday, June 1, 2011

In profundis Progress (6/1)

More boring stuff.  The pyglet changeover continues.

Someone in comments in the last one asked if I was sure that changing to pyglet would be a net performance improvement.  I don't know for sure; he is right, the reputation I have of it is largely anecdotal.

However it does look like, as far as rendering goes, pyglet is rather more flexible.  Or at least the way I was doing it before was less flexible.  Either way, I'm taking the opportunity to change the rendering system a bit.  Which is, again, not much to show.  (Well this is a development diary, heh.  A lot of development, especially in the early phases, looks like this.)

Monday, May 30, 2011

In Profundis Progress (5/28)

Work on switching over to pyglet continues.  Also redoing the graphics for performance improvements.  Not particularly interesting I know.  Right now most of the work has been infrastructure, gruntwork, and preparation for... the future....