zondag 9 juli 2023
LEGO Othello board
zaterdag 1 april 2023
Shed Skin restricted-Python-to-C++ compiler 0.9.7
I have just released version 0.9.7 of Shed Skin, a restricted-Python-to-C++ compiler. The highlight of this release is native Windows support, by moving to CMake (and Conan). Shakeeb Alireza came up with this idea and did most of the implementation. So to build something on Windows, one doesn't need a weird emulation layer like MingW anymore, just Visual Studio build tools, CMake and Conan (popular tools that many will already have installed). He also made sure that most things work under OSX. Here is a screenshot of an (also) new DOOM-engine example running under windows:
With the recent Python 3 and now native Windows support (plus an ever growing Python community), I'm hoping the project will see more usage and feedback/contributions over the coming years. Please consider joining the project, as there is always enough to do!
Besides other contributions from Folkert van Heusden and Humhue, the release comes with many other improvements, such as support for relative imports, the walrus operator and struct.pack_{from, into}. See here for the full release notes.
dinsdag 28 februari 2023
Fast DOOM WAD renderer in 999 lines of Python
For the longest time, I've wanted to re-implement the original DOOM engine in Python, and compile it with Shedskin to get reasonable performance. So when I finally ran across a pretty small engine written in Java, by Leonardo Ono, I decided to convert his version to Python.
I left out some optimizations (most notably "visplanes"), for readability and in order to keep everything under 1000 lines of code (while following PEP8). So it could run quite a bit faster still. This is including a WAD loader and interactive Pygame wrapper, that makes it almost feel like you are playing DOOM.
It's interesting how using Python (using just CPython) seems to be about as fast as using assembler back in the day.
This video shows the day-and-night difference in FPS after compilation using Shedskin.
The source code can be found in the Shedskin examples directory.
I may revisit the code now and then, to try and improve readability by adding comments and/or refactoring parts. Patches in this direction very much welcome of course.