Skip to main content

Overview

While Shed Skin is excellent for compute-intensive algorithms, some of the most impressive examples are full-featured applications that demonstrate its ability to handle complex, real-world software. This page highlights the most notable examples that showcase Shed Skin’s practical capabilities.

DOOM Renderer

Lines of code: 666
Category: Game engine
Speed: ~10-20x faster than CPython
DOOM Screenshot A complete WAD (game data file) rendering engine that can play DOOM levels with impressive performance.

What it does

  • Loads and parses DOOM1.WAD files
  • Renders 3D environments using classic DOOM algorithms
  • Handles player movement and game state
  • Plays background music (FLAC support)

Performance Impact

Watch this video demonstrating the dramatic difference in performance before and after Shed Skin compilation. The compiled version runs smoothly at playable frame rates, while the Python version is extremely sluggish.

Running the Example

Code Snippet

The DOOM example showcases complex data structure handling and real-time rendering algorithms that benefit greatly from compilation.

Commodore 64 Emulator

Lines of code: 3,332
Category: Emulator
Speed: Fast enough for real-time emulation
C64 Screenshot A full Commodore 64 emulator that runs classic C64 programs and games.

Features

  • Complete 6502 CPU emulation
  • VIC-II graphics chip emulation
  • SID sound chip emulation
  • CIA timer/IO emulation
  • Loads T64, D64, and PRG files
  • Sprite handling
  • Joystick support

Project Structure

Running the Example

Why It’s Impressive

Emulating a complete computer system requires:
  • Cycle-accurate CPU emulation
  • Real-time graphics rendering
  • Complex state management
  • Proper timing and synchronization
Shed Skin’s performance makes this possible in Python, achieving frame rates suitable for interactive use.

Pylot Ray Tracer

Lines of code: 943
Category: Graphics rendering
Features: Multiprocessing support
Pylot Screenshot A sophisticated ray tracer that produces photorealistic images with advanced lighting effects.

Features

  • Realistic lighting and shadows
  • Reflection and refraction
  • Multiple primitive types (spheres, planes, etc.)
  • Multiprocessing for parallel rendering
  • High-quality output

Running the Example

Performance

Ray tracing is extremely compute-intensive, making it an ideal use case for Shed Skin. The compiled version achieves 20-40x speedup over pure Python, turning impractical render times into reasonable ones.

PyCSG - Constructive Solid Geometry

Lines of code: 212
Category: 3D modeling
PyCSG Screenshot Constructive Solid Geometry (CSG) allows complex 3D shapes to be created by combining simple primitives using boolean operations (union, intersection, subtraction).

Capabilities

  • Boolean operations on 3D solids
  • STL file export
  • Complex geometric calculations
  • Mesh generation

Code Example

Use Cases

  • 3D modeling and CAD
  • Procedural geometry generation
  • Game level design
  • 3D printing preparation

Othello Engine

Lines of code: 341 (othello2)
Category: Game AI
Othello Screenshot A strong Othello (Reversi) game engine with sophisticated AI.

Features

  • Alpha-beta pruning search
  • Position evaluation
  • Move generation and validation
  • Human vs Computer play
  • Strong playing strength

Code Example

Performance Impact

Board game AI requires evaluating millions of positions. Shed Skin’s speedup allows:
  • Deeper search (more moves ahead)
  • Stronger play within time limits
  • Real-time interactive response

Chess Engine

Lines of code: 316 (chess), 285 (sunfish)
Category: Game AI
Two different chess engines demonstrating different design approaches.

Chess.py Features

  • Alpha-beta search with quiescence
  • Move generation using the 0x88 board representation
  • Position evaluation
  • Legal move validation

Code Example

0x88 Board Representation

The 0x88 trick uses a 160-element array (16x10) where the extra space allows fast boundary checking using bitwise operations.

NES Emulator (Pygasus)

Lines of code: 1,510
Category: Emulator
A Nintendo Entertainment System emulator capable of running classic NES games.

Features

  • 6502 CPU emulation
  • PPU (Picture Processing Unit) graphics
  • APU (Audio Processing Unit) sound
  • Mapper support for different cartridge types
  • Controller input

Performance Requirements

NES emulation requires:
  • Processing ~1.79 MHz CPU cycles
  • Rendering 60 frames per second
  • Audio generation at 44.1 kHz
  • Real-time synchronization
Shed Skin makes this achievable with reasonable performance.

Advanced Ray Tracers

MiniLight

Lines of code: 442
Category: Global illumination
An advanced ray tracer implementing physically-based rendering:
  • Monte Carlo path tracing
  • Global illumination
  • Realistic light transport
  • HDR output

Path Tracing

Lines of code: 219
Category: Ray tracing
Modern path tracing algorithm:
  • Unbiased rendering
  • Physically accurate materials
  • Indirect lighting
  • Soft shadows and ambient occlusion

Performance Comparison

This type of code runs 20-40x faster with Shed Skin, making high-quality renders practical.

Compression Algorithms

Tarsalzp

Lines of code: 868
Category: Data compression
A sophisticated data compression algorithm implementing:
  • LZMA-style compression
  • Range encoding
  • Dictionary compression
  • High compression ratios

Performance Critical Code

Compression algorithms involve:
  • Heavy bit manipulation
  • Hash table operations
  • Sequential data processing
  • Buffer management
Shed Skin’s compiled output handles these operations efficiently, achieving 15-25x speedup.

Scientific Computing

Quantum Monte Carlo (Quameon)

Lines of code: 1,194
Category: Quantum physics simulation
Quantum Monte Carlo algorithms for simulating quantum systems:
  • Variational Monte Carlo
  • Diffusion Monte Carlo
  • Random walk simulations
  • Statistical analysis

Barnes-Hut Simulation

Lines of code: 404
Category: N-body physics
Efficient gravitational force calculation:
The Barnes-Hut algorithm reduces N-body simulation from O(N²) to O(N log N), and Shed Skin makes it fast enough for real-time visualization.

Why These Examples Matter

These real-world examples demonstrate that Shed Skin can handle:
  1. Large codebases: Thousands of lines of complex code
  2. Complex algorithms: Emulators, game engines, ray tracers
  3. Real-time performance: Interactive applications and simulations
  4. Multiple modules: Projects spanning many files
  5. Extension modules: Integration with existing Python code

Running Examples with GUI

Many examples require pygame or other graphics libraries:

Performance Summary

Learning from Real-World Code

These examples are excellent for learning:
  • Code organization: How to structure larger projects
  • Type discipline: Maintaining consistent types throughout
  • Performance patterns: What code patterns work well
  • Module interaction: How to split code across files
  • Extension design: Creating Python-importable modules
Explore the examples directory to see the full source code for all these projects.