https://github.com/unicodex/pcpc
Python CFFI Performance Comparison
https://github.com/unicodex/pcpc
cffi comparison native nim nim-lang nim-language nuitka performance performance-analysis performance-metrics performance-testing python python-lib python-library python3
Last synced: about 2 months ago
JSON representation
Python CFFI Performance Comparison
- Host: GitHub
- URL: https://github.com/unicodex/pcpc
- Owner: UNIcodeX
- Created: 2019-03-13T17:49:22.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T20:53:40.000Z (over 5 years ago)
- Last Synced: 2023-10-20T02:09:05.638Z (over 1 year ago)
- Topics: cffi, comparison, native, nim, nim-lang, nim-language, nuitka, performance, performance-analysis, performance-metrics, performance-testing, python, python-lib, python-library, python3
- Language: Python
- Homepage:
- Size: 1.72 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PCPC (Python CFFI Performance Comparison)
The purpose of this repo is to compare different options for creating Python modules and their efficiency, relative to each-other.







# TODOs
- *Add more benchmarks*# How Libraries Were Built
- **Nuitka** -- `nuitka3 --lto --module /path/to/lib.py`
- **Cython** -- `cythonize -a -i /path/to/lib.pyx`
- **Nim** -- `nim c --app:lib -d:release --gc:markAndSweep --out:lib.[so|pyd] /path/to/lib.nim`
- **V** -- `v -shared -prod /path/to/lib.v`# Current Benchmark Output
```console
$ ./benchmark_all.shRunning benchmark 'base64'
---------------------------------------------------------
Python : 0.1405s 1.00x
Nuitka : 0.1410s 1.00x
Cython : 0.1441s 0.97x
Nim : 0.0845s 1.66xRunning benchmark 'fibonacci_iterative' to 100000 places.
---------------------------------------------------------
Python : 1.1194s 1.00x
Nuitka : 1.1471s 0.98x
Cython : 0.0007s 1,559.35x
Numba : 0.0004s 2,980.38x
Nim : 0.0007s 1,499.98x
V : 0.0029s 383.67xRunning benchmark 'fibonacci_recursive' to 30 places.
---------------------------------------------------------
Python : 1.6359s 1.00x
Nuitka : 1.0064s 1.63x
Cython : 0.3227s 5.07x
Numba : 0.0582s 28.13x
Nim : 0.0182s 89.79x
V : 0.0585s 27.97xRunning benchmark 'json_loads'.
_NOTE:_ JSON parsing within Nim is quite fast. I believe
there is extra overhead from converting each value to a
string. There is probably also more efficient way to do
pass this data back to Python. Suggestions welcome.
---------------------------------------------------------
Python : 0.1633s 1.00x
Nuitka : 0.1583s 1.03x
Cython : 0.1573s 1.04x
Numba : 0.5923s 0.28x
Nim : 0.5128s 0.32xRunning benchmark 'gen_range'.
---------------------------------------------------------
Python : 0.4937s 1.00x
Nuitka : 0.4567s 1.08x
Cython : 0.1428s 3.46x
Numba : 0.3121s 1.58x
Nim : 0.3362s 1.47x
```Benchmarks were ran in a VM with the following specs.
```
OS: Antergos
Kernel: x86_64 Linux
Packages: 908
Shell: zsh 5.7.1
CPU: Intel Core i7-6700
GPU: vboxdrmfb
RAM: 1115MiB / 3000MiB
```# Suggestions
Suggestions for more benchmarks are welcome, as well as PRs.