Skip to content

Commit

Permalink
Python3 with Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbalaci committed Aug 12, 2022
1 parent ae66042 commit b976fe6
Show file tree
Hide file tree
Showing 12 changed files with 460 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ Münchausen number is less than 440 million.

Dates are in `yyyy-mm-dd` format.

**2022-07-30:** Ruby and Crystal codes were added.

**2022-07-28:** Python 3.11 beta was added.
**2022-08-12:** Python3 with Rust was added.

**2022-07-28:** All tests were re-run on my new (faster) computer.
You can find the specifications of this machine below.
Expand Down Expand Up @@ -492,6 +490,26 @@ Notes:
[see source](python311b)


### Python 3 with Rust

* Python 3.10.5
* rustc 1.62.1 (e092d0b6b 2022-07-16)
* Benchmark date: 2022-08-12 [yyyy-mm-dd]

| Compilation | Runtime (sec) | -- | -- |
|-----|:---:|:---:|:---:|
| `# see v1 in Makefile && ./start_v1.sh` | 40.263 ± 1.152 | -- | -- |

Notes:

* The real work is done in Rust. The Rust code is compiled as a shared library.
The Python code just calls a function implemented in Rust.
* The Rust code uses [pyo3](https://docs.rs/pyo3).
Compilation is done with [maturin](https://github.com/PyO3/maturin).

[see source](python3_with_rust)


### Racket

* Welcome to Racket v8.5 [cs].
Expand Down
17 changes: 17 additions & 0 deletions _automation/python3_with_rust.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"section_name": "Python 3 with Rust",
"compilers": ["python3", "rustc"],
"output_file": "--",
"table_headers": [
"Compilation",
"Runtime (sec)",
"--",
"--"
],
"special": [
{
"compile": "v1",
"run": "run1"
}
]
}
72 changes: 72 additions & 0 deletions python3_with_rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/target

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
.venv/
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
include/
man/
venv/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
pip-selfcheck.json

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

.DS_Store

# Sphinx documentation
docs/_build/

# PyCharm
.idea/

# VSCode
.vscode/

# Pyenv
.python-version
250 changes: 250 additions & 0 deletions python3_with_rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions python3_with_rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "python3_with_rust"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "python3_with_rust"
crate-type = ["cdylib"]

[dependencies]
once_cell = "1.13.0"
pyo3 = { version = "0.16.5", features = ["extension-module"] }
Loading

0 comments on commit b976fe6

Please sign in to comment.