Skip to main content

rustdef

Test PyPI version

Jupyter extension for jupyter notebooks and rust users.

You can define functions in rust and run them as python functions. This extension is built on PyO3 and maturin.

Examples

Prerequisite

Install

$ pip install rustdef

Usage

Define rust functions,

%%rustdef
#[pyfunction]
fn my_func(x: i64, y: &str) -> i64 {
    println!("{}", y);
    x + y.len() as i64
}

Add dependencies, (e.g. num crate)

%rustdef deps add num@0.4.0

Defined dependencies are valid only in the current notebook.

Show dependencies,

%rustdef deps show
num = "0.4.0"

[pyo3]
version = "0.13.2"
features = [ "extension-module",]

pyo3 is included by default.

Develop

How does it work?

Roughly, definitions in rustdef are available in python after the following steps.

  1. Each rustdef magic cell is populated with the module definition of pyo3
  2. A new crate is generated for the rustdef cell
  3. The crate is compiled into a python wheel by maturin
  4. Install the wheel with pip
  5. Functions with #[pyfunction] attributes are exported into the interpreter namespace in notebooks
  6. Ready to call the function in notebooks!

Build

maturin is required.

$ pip install maturin
$ maturin build
$ pip install target/wheels/rustdef-{version}-{python}-{platform}.whl

ToDo

  • execute within rustdef cell
  • class/module supports
  • customizable module name
  • use functions defined in another cell
  • verbose flag
  • serde support
  • windows support

Metadata

Release files for rustdef 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for rustdef 0.4.0
File
rustdef-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
rustdef-0.4.0-cp311-cp311-macosx_10_7_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.7+ x86-64 Details
rustdef-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
rustdef-0.4.0-cp310-cp310-macosx_10_7_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.7+ x86-64 Details
rustdef-0.4.0-cp39-cp39-manylinux_2_34_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ x86-64 Details
rustdef-0.4.0-cp39-cp39-macosx_10_7_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.7+ x86-64 Details
rustdef-0.4.0-cp38-cp38-manylinux_2_34_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.34+ x86-64 Details
rustdef-0.4.0-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details
rustdef-0.4.0-cp37-cp37m-manylinux_2_34_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.34+ x86-64 Details
rustdef-0.4.0-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details

Total release size: 13.6 MB

Release files / rustdef-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL rustdef-0.4.0-cp311-cp311-manylinux_2_34_x86_64.whl
Size 1.9 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
665440215993540240240745f2cf34229e4a8373de348a8b3e75946af25cfb33
BLAKE2b-256 checksum
How to use checksums
fac4685584cfc30926c0c4d79083f07de769dbf42da00eccb5b13ef93c7bf142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp311-cp311-macosx_10_7_x86_64.whl

Download URL rustdef-0.4.0-cp311-cp311-macosx_10_7_x86_64.whl
Size 855.6 kB
Tags CPython 3.11 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
0c6e5d26bc8b6649720a96353a568c83a7b1b01a7db89938d9f606259c7c6933
BLAKE2b-256 checksum
How to use checksums
7d0db7a74d4366babda1bbd22aa37bc4de8c1fe56e0f15346edea2c5a0a8ee26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL rustdef-0.4.0-cp310-cp310-manylinux_2_34_x86_64.whl
Size 1.9 MB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
2f9037d9dfe0651546ba6841abd7b1e1c127d98153f15f74f4595228f8e36259
BLAKE2b-256 checksum
How to use checksums
60812c39ab79fdf49a72fc1f74f8701ad038289fa21f5a00e3b006267d60c1d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp310-cp310-macosx_10_7_x86_64.whl

Download URL rustdef-0.4.0-cp310-cp310-macosx_10_7_x86_64.whl
Size 855.6 kB
Tags CPython 3.10 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
fdf49d685023abaa66cd7ee6d8a359f4bd5015a536c67ed1eec5a0420573c282
BLAKE2b-256 checksum
How to use checksums
97c1b308ac86e8f635134f063b8f87277ecca5d2cc997112648bd02e176300c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp39-cp39-manylinux_2_34_x86_64.whl

Download URL rustdef-0.4.0-cp39-cp39-manylinux_2_34_x86_64.whl
Size 1.9 MB
Tags CPython 3.9 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
1ddc9002d95c6f4025115916bd3c619271f193acf70d7ce7177f9e438fbc1f46
BLAKE2b-256 checksum
How to use checksums
271160f4706289133e6b07cc6848cc9ed709302a356087dde4c4f59cf1d98f24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp39-cp39-macosx_10_7_x86_64.whl

Download URL rustdef-0.4.0-cp39-cp39-macosx_10_7_x86_64.whl
Size 855.6 kB
Tags CPython 3.9 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
589095778f54d2a4002414222597da5649b717a113ae79fed8b83cee2bde4f3e
BLAKE2b-256 checksum
How to use checksums
4cf03f7f9fca8f1f4b38b0d51b8cffaa5914ea81067bfe21b0a2464eed62ef8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / rustdef-0.4.0-cp38-cp38-manylinux_2_34_x86_64.whl

Download URL rustdef-0.4.0-cp38-cp38-manylinux_2_34_x86_64.whl
Size 1.9 MB
Tags CPython 3.8 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
a595fbdcae5e8ba9b4c7c62bb3cf6f8bf940dabada189fa024f99fc259dec3fa
BLAKE2b-256 checksum
How to use checksums
047ed6612e3b6a1bfd4d42ee4b3eac0edc229afd14a0eb5b650352ed81f266a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / rustdef-0.4.0-cp38-cp38-macosx_10_7_x86_64.whl

Download URL rustdef-0.4.0-cp38-cp38-macosx_10_7_x86_64.whl
Size 855.3 kB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
2442e568afc416a998be26eed235b513c8ecb4838b9c60bf3564974e516f7ca7
BLAKE2b-256 checksum
How to use checksums
97fc28e7701052f840911bb648e9bec6f12f80d0895b3ee342a1eb0923ca3203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp37-cp37m-manylinux_2_34_x86_64.whl

Download URL rustdef-0.4.0-cp37-cp37m-manylinux_2_34_x86_64.whl
Size 1.9 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7405adc859c907e665db34c3b9f85fc70207baa4eb1880c140207e3fa6278bb5
BLAKE2b-256 checksum
How to use checksums
c9c892ecddea9b240dcb8921ef9de7d8074ca8e1a8dab46606ce881e97f76e24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / rustdef-0.4.0-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL rustdef-0.4.0-cp37-cp37m-macosx_10_7_x86_64.whl
Size 855.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
2aeff62028949b20d93975164e244296f26365a381ae0f7a89328e5ba6352119
BLAKE2b-256 checksum
How to use checksums
e3e3b99361013af4dbcdfe3a5e7967ca4c62030a9a4122da7377b45dc7e5a535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page