Phil Hassey - game dev blog
Phil Hassey as Wolverine
"What kind of
arrogant jerk
has a website like this?"

Taking on Shed-Skin

There’s this swell python to c++ compiler called shedskin. It’s really interesting. I took a few hours tonight to make it do something:

shedskin-julia2.png shedskin-julia4.png shedskin-julia3.png

Yep those are real-time julia fractals 🙂 If you dare – check it out (make sure python and SDL-devel are all setup):

wget http://www.imitationpickles.org/tmp/juliashed.zip ; unzip juliashed.zip ; cd juliashed ; python ss.py test.py ; make ; ./test

I’ve sent Mark an excessively long e-mail with my comments. I’ll spare you the trouble and just give the highlights:

  • My C++ skills don’t exist
  • python descriptors are probably the feature I would like to see most – so I could implement pygame.Rect style Rects!
  • misc packaging issues (see his previous blog post)
  • The README says it “does not scale very well beyond a few hundred lines” – so I guess I’ll wait a while before I try to make a game with it. (Even simple games I make are around 1500 lines.)

Anyway, it’s a cool project. I plan to keep an eye on it.

This just in – I made a python+pygame equivalent. The shed-skin version is ~100x faster! Also, the black areas in the middle of the shapes are caused by my access of out-of-bounds palette entries. I added the -b (bounds check) to the command line and fixed the bug. The bounds check gave me no noticeable speed penalty.

5 Responses to “Taking on Shed-Skin”

  1. Richard Says:

    On Ubuntu I also needed to install libgc-dev

  2. Mark Dufour Says:

    Thanks for playing around with shed skin. I’ll reply to your mails of course, but for anyone else interested:

    -I don’t see me adding support for descriptors and other similar features any time soon. Shed Skin is really about ‘writing C++ with Python syntax’. Type inference and code generation would become too complicated otherwise. Sure you won’t be able to do anything you want, but it does keep shed skin small and effective for cases where you can apply it, ‘like a knife’.

    -I’ll be looking into packaging issues for the next version.

    -The largest program compiled so far is about 1,600 lines (including comments.) The ss-progs.tgz file on the homepage contains several other working programs of over 500 lines. How well things scale depends on how difficult it is to analyze a program. This usually translates to how much you overload builtin containers with different types of elements. If you use 20 lists each with different types of elements, it takes a while for the analysis to unravel the different ‘list contexts’. If you use several custom classes to hold stuff, analysis will typically proceed much faster. In the future, improvements in type inference (I spent most time on other details so far), and feeding shed skin with profiling information should allow it to easily scale beyond 1,500 lines in most cases.

    Btw, I also managed to compile a pygame application before. It’s a bit larger, and I used the Python C/API to talk directly to Pygame, which seems a bit more cumbersome. See this blog entry:
    http://shed-skin.blogspot.com/2006_07_01_archive.html. This program is one of the test cases contained in ss-progs.tgz from the homepage.

  3. Mark Dufour Says:

    of course the link should be:
    http://shed-skin.blogspot.com/2006_07_01_archive.html

  4. Shed Skin « Problem Solving In Python Says:

    […] Today I first heard about Shed Skin (via Phil Hassey). It’s an experimental Python to C++ that promises quite a fast speed up, subject to some […]

  5. oyster Says:

    where can i find juliashed.zip now? thanx