Skip to main content

Compile Python to Optimized C++

Shed Skin is a restricted-Python-to-C++ compiler that translates implicitly statically typed Python programs into optimized C++ code, delivering speedups of 1-100x over CPython.

Quick start

Get up and running with Shed Skin in minutes

1

Install Shed Skin

Install using pip or your package manager:
pip install shedskin
You’ll also need a C++ compiler and the Boehm garbage collector. See the installation guide for platform-specific instructions.
2

Write compatible Python code

Create a Python file with implicitly statically typed code:
test.py
def factorial(n: int) -> int:
    if n <= 1:
        return 1
    return n * factorial(n - 1)

print(factorial(10))
Shed Skin requires implicit static typing — variables must maintain a single type throughout execution.
3

Compile to C++

Use the shedskin build command to compile your Python code:
shedskin build test
This generates optimized C++ code and compiles it into an executable in the build/ directory.
4

Run your compiled program

Execute the compiled binary for dramatic performance improvements:
./build/test
Typical speedups range from 12x to 20x compared to CPython, with some programs achieving 100x improvements.

Key features

Everything you need to accelerate Python performance

Type inference

Automatic type inference eliminates the need for explicit type annotations while generating statically typed C++ code.

Standalone executables

Generate fully compiled executables or extension modules that can be imported into larger Python programs.

30+ standard modules

Built-in support for common Python modules including random, re, itertools, and more.

Exceptional performance

Achieve 1-100x speedups over CPython with typical improvements of 12-20x for computation-intensive code.

Boehm GC integration

Automatic memory management using the battle-tested Boehm garbage collector.

Extension modules

Create C++ extension modules that integrate seamlessly with your existing Python codebase.

Performance comparison

Shed Skin delivers exceptional performance improvements over CPython and other Python implementations

CPython 3.1111.4 seconds (baseline)
PyPy 3.95.8 seconds (2x faster)
Numba 0.562.5 seconds (4.5x faster)
Shed Skin 0.9.91.9 seconds (6x faster)

Benchmark: Sieve of Eratosthenes with n=100,000,000. See the full benchmark suite for more comparisons.

When to use Shed Skin

Good fit

  • Computation-intensive Python programs (hundreds to thousands of lines)
  • Code that can be made independent of external libraries
  • Performance-critical modules in larger Python applications
  • Algorithms, simulations, and numeric computations

Not recommended

  • Programs heavily dependent on unsupported libraries
  • Code using dynamic Python features (eval, getattr, *args)
  • Very large codebases (>6,000 lines) due to type inference limitations
  • Applications requiring arbitrary-size arithmetic or full Unicode support

Community & support

Get help and connect with other Shed Skin users

GitHub Discussions

Ask questions, share projects, and discuss features with the community.

Issue Tracker

Report bugs, request features, or browse known issues.

Contributing

Learn how to contribute code, documentation, or supported modules.

FAQ

Find answers to common questions about Shed Skin usage and limitations.

Ready to accelerate your Python code?

Start compiling Python to optimized C++ and achieve dramatic performance improvements.

Get Started Now