跳转到主要内容

Shed Skin是一个受限的Python到C++编译器。

项目描述

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

Shed Skin

Shed Skin是一个转译器,可以将纯Python 3程序翻译成优化的C++。它可以生成独立程序或扩展模块,这些模块可以在更大的Python程序中使用。

除了类型限制外,程序不能自由使用Python标准库(尽管目前支持约25个常见模块,例如random和re)。此外,并非所有Python功能,如嵌套函数和可变数量的参数,都受支持(有关详细信息,请参阅文档)。

对于一组80个非平凡程序(总行数超过25,000行(sloccount)),测量显示与CPython相比的平均速度提高1-100倍。

用法

在Linux/OSX下编译和运行‘hello, world!’(test.py)示例

shedskin build test
build/test

在Windows下

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

限制

Shed Skin只支持Python的一个受限子集,因此不应该期望某个程序在经过任何修改后都能编译,如果可能的话。有关限制的概述,请参阅文档

安装

Shed Skin依赖于一些其他项目,例如Boehm垃圾收集器。请参阅文档了解如何安装这些。

比较

Shed Skin的'sieve'示例(n=100000000)和几个Python实现/优化器的计时

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)

请注意,Numba默认整数类型为int64,而Shed Skin默认为int32。当使用shedskin –long时,性能实际上相等。

屏幕截图

以下是一些示例程序的实际操作截图

(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

此视频展示了DOOM示例在编译前后的性能差异

贡献者

以下人员为Shed Skin的开发做出了贡献

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

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

shed_skin-0.9.9.tar.gz (1.9 MB 查看哈希值)

上传时间 源代码

构建分发

shed_skin-0.9.9-py3-none-any.whl (346.1 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWSAWS 云计算和安全赞助商 DatadogDatadog 监控 FastlyFastly CDN GoogleGoogle 下载分析 MicrosoftMicrosoft PSF赞助商 PingdomPingdom 监控 SentrySentry 错误日志 StatusPageStatusPage 状态页面