Before you begin
Make sure you have Shed Skin installed. If not, see the installation guide.Shed Skin works with a restricted subset of Python. Your program must be implicitly statically typed and cannot use dynamic features like
eval or getattr.Compile your first program
Let’s compile the classic “Hello, World!” program and see Shed Skin in action.Create a Python file
Create a file called This simple program will help you verify that Shed Skin is working correctly.
test.py with the following content:test.py
Compile the program
Run the Shed Skin compiler on your Python file:This command translates your Python code to C++, then compiles it to a native binary. The
--conan flag on Windows downloads required dependencies automatically.You should see output indicating the translation and compilation process. When complete, you’ll find the generated files in a build directory.Try a more complex example
Let’s compile a program that does some real computation to see Shed Skin’s performance benefits.Create a computation-intensive program
Create a file called This program renders a Mandelbrot fractal and measures execution time.
mandelbrot.py:mandelbrot.py
Build options
Shed Skin provides several options to optimize your compiled programs:Disable bounds checking
For maximum performance, disable array bounds checking:IndexError.
Integer and float precision
Control the size of numeric types:Use
--int64 if your program needs to handle integers larger than 2³¹-1.Building extension modules
You can also compile Python code as extension modules that can be imported by regular Python programs. Createsimple_module.py:
simple_module.py
Next steps
Now that you’ve compiled your first programs, learn more about:Typing restrictions
Understand the static typing requirements
Python subset
Learn which Python features are supported
Writing compatible code
Best practices for Shed Skin programs
Optimization guide
Get the best performance from your code
Troubleshooting
Compilation errors
If compilation fails, common issues include:- Dynamic typing: Variables changing types between int and string
- Mixed collections: Lists containing different types like
[1, 'hello'] - Unsupported features: Using
*args,**kwargs, or nested functions
Performance not as expected
- Use
--noboundsto disable bounds checking - Profile your code to find bottlenecks
- Reduce small object allocations (lists, tuples, class instances)
- See the optimization guide for more tips