Overview
Shed Skin delivers significant performance improvements over standard Python implementations. Measurements across 80+ example programs show typical speedups of 1-100x over CPython, with an average of 20x and median of 12x.Sieve Benchmark
The classic sieve of Eratosthenes prime number algorithm provides a clear performance comparison across different Python implementations and optimizers.Results (n=100,000,000)
Code Example
Here’s the sieve implementation used in benchmarking:Optimization Flags
Shed Skin offers additional optimization flags:--nowrap: Disable bounds checking on list/string operations--nobounds: Alias for--nowrap--int64: Use 64-bit integers (default is 32-bit)
Comprehensive Performance Comparison
The following chart compares Shed Skin and PyPy speedups versus CPython 3.10 across most Shed Skin examples:
Note: These measurements were performed for the git tag ‘performance_comparison’. PyPy was allowed to stabilize (warm up JIT) before measuring.
Key Observations
- Consistent speedups: Shed Skin provides reliable performance improvements across diverse workloads
- Predictable performance: Unlike JIT compilers, Shed Skin delivers consistent performance from the first run
- Best-case scenarios: Some examples achieve 50-100x speedups, particularly for numeric and algorithmic code
- Median performance: Half of all examples achieve at least 12x speedup
- PyPy comparison: Shed Skin often outperforms PyPy, especially on compute-intensive tasks
Performance by Category
Numeric Computing
Typical speedup: 20-50x Examples: mandelbrot, nbody, bh (Barnes-Hut), neural networks- Heavy floating-point computation
- Array/list operations
- Minimal Python object overhead
Algorithms
Typical speedup: 10-30x Examples: dijkstra, astar, sorting algorithms, graph algorithms- Integer arithmetic
- Data structure operations
- Tight loops
Ray Tracing & Graphics
Typical speedup: 15-40x Examples: mao, minilight, pylot, path_tracing- 3D vector operations
- Recursive algorithms
- Intensive floating-point math
Game Engines & Emulators
Typical speedup: 5-20x Examples: chess, doom, c64, pygasus- Complex state management
- Mixed integer/object operations
- Real-time performance requirements
String Processing & Compression
Typical speedup: 8-25x Examples: lz2, ac_encode, block, sha- Byte/string manipulation
- Bit operations
- Sequential processing
Methodology
Measurement Protocol
- Warm-up runs: PyPy requires several iterations to warm up its JIT compiler. We run the code 5 times before measuring (as seen in example code):
- Multiple iterations: Each benchmark runs multiple times to get stable measurements
- Same hardware: All comparisons run on identical hardware
- Same Python version: CPython 3.10 is used as the baseline
Compilation Settings
Default Shed Skin settings unless otherwise specified:- 32-bit integers (int32)
- Bounds checking enabled
- Standard optimizations (-O2 in C++ compiler)
Integer Type Performance
Shed Skin defaults to 32-bit integers while Numba defaults to 64-bit integers. This affects performance comparisons:--int64, Shed Skin and Numba performance is practically equal on the sieve benchmark.
Real-World Performance Examples
Chess Engine
Mandelbrot Fractal
Richards Benchmark
The standard Richards benchmark (task scheduling simulation): Speedup: ~18x over CPythonWhen to Expect Best Performance
Shed Skin delivers the highest speedups when your code:- Is compute-intensive: Heavy loops and calculations
- Uses basic types: Integers, floats, lists, tuples, strings
- Has clear type flow: Consistent variable usage
- Minimizes dynamic features: No eval, exec, or heavy introspection
- Works with supported modules: Uses the 25+ built-in modules