I've been on a Vexillium team meeting for the last few days, and I can say that it was very inspiring. Among other things, I had the chance to give a talk about old-school 2D graphic effects, where, inter alia, I've talked about metaballs, and I've shown a not-too-fancy, but still working, "educational" metaball implementation (without ANY optimization, and I mean ANY) in SDL+C++ (see the clickable screenshot on the left). The lack of optimisation was so bad (14 FPS at my PC), that I had to create a version that used 4 cores just to present a smooth animation ;>. Links to the metaball source code (and binaries) are at the bottom of this post, and should appear in the code section in a few days (as soon as I create a code section that is ;p).

At the meeting we also talked a little about JITs, and a question arouse - does Python has JIT? It seems it doesn't, however there is an external JIT called Psyco, that is operated from the script source. You just add import psyco, and then tell the JIT what functions it should compile - psyco.bind(function), or tell it to compile everything - psyco.full(), and thats it. You don't have to change the Python interpreter, patch it, or anything like that - You just install or compile+install Psyco, import, and it works.

I have to admit that I really liked the way Psyco works, and so I decided to try it out on a real thing. I've made a port of metaballs to Python (no opt. included), and I've checked if Psyco makes a difference. It does. Without psyco, my Python metaballs rendered one frame 2.5 seconds (talk about slow ;p). With Psyco turned on for some functions, the rendering time came down to 1.1 sec, and if Psyco was in "full" mode, then another 0.1 sec was gained. Maybe 1 sec isn't to fast for metaballs, but 250% gain ratio by just adding 3 lines of code seems really good! Btw, I've used the pygame for rendering (see screenshot on the right) - the library seems very usable.

OK, thats all for today.
P.S. In the menu, I've added a missing (for unknown reasons) link to the RSS feeds. In a few days I should be able to create a section with some code snippets and advisories, and move the stuff from old blogs there.

metaballs.cpp (7kb, libSDL is required)
metaballs.exe (7kb, libSDL DLL is required)
metaballs_4c.cpp (9kb, libSDL is required)
metaballs_4c.exe (7kb, libSDL DLL is required)
metaballs.py (5kb, pygame is required)
metaballs_psyco.py (5kb, pygame and psyco are required)

Add a comment:

URL (optional):
Math captcha: 8 ∗ 5 + 6 =