Friday, June 29, 2007

Shed Skin 0.0.22

after being bogged down with work for a few weeks, I got back to development again. the trigger was a proof-of-concept patch sent in by Harri Pasanen for generating extension modules. previously I was waiting for someone else to fully tackle this, but his patch was quite simple, and I found out it easily works under mingw, too. so I generalised things a bit, and released it as part of version 0.0.22. the process of building an extension module is now quite simply 'ss -e ..' and 'make' (note it doesn't work under OSX, yet).

there are some limitations though as to the way this works:

-only builtin scalar and containers can be passed/returned (int, float, str, list, tuple, dict, set)
-arguments/returned objects are completely copied/converted at call/return time (i.e., including contained objects)
-global variables are considered constant, and converted at module initialization time

consider this simple program,

some_var = [1,2,3]

def some_func(x):
return 2*x

if __name__ == '__main__':
some_func(1) # obviously, this is needed for type inference to work

to compile this down to an extension module, simply use the new '-e' command-line parameter:

ss -e mod_name

that's it. now the program can be used from an arbitrary python program/prompt:

>>>import mod_name

I'm hoping someone else can add support for custom classes and find out how to get this to work under OSX!