Skip to main content

Shed Skin is a restricted-Python-to-C++ compiler.

Project description

https://img.shields.io/travis/shedskin/shedskin.svg http://img.shields.io/badge/benchmarked%20by-asv-green.svg?style=flat

Shed Skin

Shed Skin is a transpiler, that can translate pure, but implicitly statically typed Python 3 programs into optimized C++. It can generate stand-alone programs or extension modules that can be imported and used in larger Python programs.

Besides the typing restriction, programs cannot freely use the Python standard library (although about 25 common modules, such as random and re, are currently supported). Also, not all Python features, such as nested functions and variable numbers of arguments, are supported (see the documentation for details).

For a set of 80 non-trivial programs (at over 25,000 lines in total (sloccount)), measurements show a typical speedup of 1-100 times over CPython.

Usage

Compile and run the ‘hello, world!’ (test.py) example under Linux/OSX:

shedskin build test
build/test

Under Windows:

shedskin build --conan test
build/Debug/test.exe

Restrictions

Shed Skin only supports a restricted subset of Python, so one should not expect a given program to compile without any changes, if possible at all. See the documentation for an overview of the limitations.

Installation

Shed Skin depends on some others projects, such as the Boehm garbage collector. Please see the documentation on how to install these.

Comparison

Some timings for the Shed Skin ‘sieve’ example (n=100000000) and several Python implementations/optimizers:

cpython 3.10.6:     13.4 seconds
cpython 3.11.0:     11.4
nuitka 0.6.16:      11.4
pypy 3.9.12:        5.8
numba 0.56.4:       2.5
shedskin 0.9.9:     1.9
shedskin 0.9.9:     1.8  (using --nowrap --nobounds)

Note that Numba defaults to int64 as integer type, while Shed Skin defaults to int32. Performance is practically equal when using shedskin –long.

Screenhots

Some screenshots of the example programs in action:

(pylot)

https://raw.githubusercontent.com/shedskin/shedskin/master/docs/assets/screenshots/harm3.png

(c64)

https://raw.githubusercontent.com/shedskin/shedskin/master/docs/assets/screenshots/harm1.png

(pycsg)

https://raw.githubusercontent.com/shedskin/shedskin/master/docs/assets/screenshots/harm7.png

(othello2)

https://raw.githubusercontent.com/shedskin/shedskin/master/docs/assets/screenshots/harm6.png

(doom)

Left floating image

This video shows the dramatic difference in performance for the DOOM example before and after compilation

Contributors

The following people have contributed to Shed Skin development:

Shakeeb Alireza
Hakan Ardo
Brian Blais
Paul Boddie
François Boutines
Djamel Cherif
James Coughlan
Mark Dewing
Mark Dufour
Artem Egorkine
Michael Elkins
Moataz Elmasry
Enzo Erbano
Ernesto Ferro
Salvatore Ferro
FFAO
Victor Garcia
Luis M. Gonzales
Fahrzin Hemmati
Folkert van Heusden
Karel Heyse
Humhue
Johan Kristensen
Kousuke
Denis de Leeuw Duarte
Van Lindberg
David Marek
Douglas McNeil
Andy Miller
Jeff Miller
Danny Milosavljevic
Joaquin Abian Monux
John Nagle
Harri Pasanen
Brent Pedersen
Joris van Rantwijk
Retsyo
Pierre-Marie de Rodat
Jérémie Roquet
Mike Schrick
SirNotAppearingInThisTutorial
Paul Sokolevsky
Thomas Spura
Joerg Stippa
Dan Stromberg
Dave Tweed
Jaroslaw Tworek
Tony Veijalainen
Yuri Victorovich
Pavel Vinogradov
Jason Ye
Liu Zhenhai
Joris van Zwieten

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shed_skin-0.9.9.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

shed_skin-0.9.9-py3-none-any.whl (346.1 kB view details)

Uploaded Python 3

File details

Details for the file shed_skin-0.9.9.tar.gz.

File metadata

  • Download URL: shed_skin-0.9.9.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.15 CPython/3.10.12

File hashes

Hashes for shed_skin-0.9.9.tar.gz
Algorithm Hash digest
SHA256 46db2e101b87b15a05deca9abc0ff5624b54949cd81be0b010eb737095a580f8
MD5 db4b18959e15c0c0a232d47e6682929b
BLAKE2b-256 ef8a57a1da4f289032a63654b3709cd6afaa522e45d3f1d09652f01a26a23168

See more details on using hashes here.

File details

Details for the file shed_skin-0.9.9-py3-none-any.whl.

File metadata

  • Download URL: shed_skin-0.9.9-py3-none-any.whl
  • Upload date:
  • Size: 346.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.15 CPython/3.10.12

File hashes

Hashes for shed_skin-0.9.9-py3-none-any.whl
Algorithm Hash digest
SHA256 59a5adc4c8d49b8e9cbdf14a4ad7c41ae811df0961ee6ca9b1197e1cfc093c4e
MD5 aa570d8f6e868bf1fccd43124a84a5d3
BLAKE2b-256 afd152722e421574a4534764455fdf921b9fd302b91cc561a735d454b77ddb8c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page