{"id":15569446,"url":"https://github.com/johnthagen/rust-to-python","last_synced_at":"2025-10-12T16:06:41.796Z","repository":{"id":37328240,"uuid":"489674448","full_name":"johnthagen/rust-to-python","owner":"johnthagen","description":"A mapping of Rust features and tooling to Python","archived":false,"fork":false,"pushed_at":"2025-07-21T12:40:08.000Z","size":40,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T16:06:23.721Z","etag":null,"topics":["algebraic-data-types","code-formatter","embedded","linting","pattern-matching","python","rust","tooling","typing","unit-testing","wasm"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnthagen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-05-07T13:00:25.000Z","updated_at":"2025-07-21T12:40:12.000Z","dependencies_parsed_at":"2024-01-13T21:54:34.071Z","dependency_job_id":"0e0a2d96-1050-4beb-9fda-8abe3d9d1e2a","html_url":"https://github.com/johnthagen/rust-to-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/johnthagen/rust-to-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnthagen%2Frust-to-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnthagen%2Frust-to-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnthagen%2Frust-to-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnthagen%2Frust-to-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnthagen","download_url":"https://codeload.github.com/johnthagen/rust-to-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnthagen%2Frust-to-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279011983,"owners_count":26085039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algebraic-data-types","code-formatter","embedded","linting","pattern-matching","python","rust","tooling","typing","unit-testing","wasm"],"created_at":"2024-10-02T17:29:03.603Z","updated_at":"2025-10-12T16:06:41.791Z","avatar_url":"https://github.com/johnthagen.png","language":null,"readme":"# Rust to Python\n\nThis repository provides a mapping from Rust tooling and language features to Python.\n\n# Tooling\n\n| Tool | Rust | Python\n| - | - | -\n| Package Repository | [crates.io][crates.io] | [PyPI][PyPI]\n| Multi-version Installation | [rustup][rustup] | [`uv python` command][uv]\n| Package Management | [Cargo][Cargo] | [uv][uv]\n| Build Executables | [Cargo][Cargo] | [PyInstaller][PyInstaller]\n| Type Checking | [Cargo][Cargo] | [Mypy]\n| Code Formatting | [Rustfmt][Rustfmt] | [Ruff Formatter][Ruff], [Ruff `isort` rules][Ruff]\n| Linting | [Clippy][Clippy] | [Ruff][Ruff]\n| Unit Testing | [`#[test]`][test] | [pytest][pytest]\n| Scripts | [cargo-script][cargo-script] | [`uv run`][uv], [Nox][Nox]\n| Upgrade to New Language Features | [`cargo fix`][cargo-fix] | [Ruff `pyupgrade` rules][Ruff]\n\n[rustup]: https://www.rust-lang.org/tools/install\n[uv]: https://docs.astral.sh/uv/\n[crates.io]: https://crates.io/\n[PyPI]: https://pypi.org/\n[Cargo]: https://doc.rust-lang.org/cargo/\n[PyInstaller]: https://pyinstaller.org/en/stable/\n[Mypy]: https://mypy.readthedocs.io/en/stable/\n[Rustfmt]: https://rust-lang.github.io/rustfmt\n[isort]: https://pycqa.github.io/isort/\n[Clippy]: https://github.com/rust-lang/rust-clippy\n[Ruff]: https://docs.astral.sh/ruff/\n[Flake8]: https://flake8.pycqa.org/en/latest/\n[test]: https://doc.rust-lang.org/book/ch11-01-writing-tests.html\n[pytest]: https://docs.pytest.org/\n[cargo-script]: https://github.com/DanielKeep/cargo-script\n[Nox]: https://nox.thea.codes/en/stable/\n[cargo-fix]: https://github.com/rust-lang/rustfix\n[pyupgrade]: https://github.com/asottile/pyupgrade\n\n\u003e For a Python project example that incorporates these tools, see \n\u003e [python-blueprint](https://github.com/johnthagen/python-blueprint).\n\n# Environments\n\n| Environment | Rust | Python\n| - | - | -\n| WASM | [wasm-pack][wasm-pack] | [PyScript][PyScript], [Pyodide][Pyodide], [CPython WASM][CPython WASM]\n| Embedded | [Embedded Rust][Embedded Rust] | [MicroPython][MicroPython], [CircuitPython][CircuitPython]\n\n[wasm-pack]: https://rustwasm.github.io/\n[PyScript]: https://pyscript.net/\n[Pyodide]: https://pyodide.org/en/stable/\n[CPython WASM]: https://github.com/ethanhs/python-wasm\n[Embedded Rust]: https://docs.rust-embedded.org/book/\n[MicroPython]: https://micropython.org/\n[CircuitPython]: https://circuitpython.org/\n\n# Language Features\n\n| Feature | Rust | Python\n| - | - | -\n| Interface | [`trait`][trait] | [`Protocol`][Protocol]\n| Generics | [`\u003cT\u003e`][Rust Generic] | [`list[T]` etc.][PEP 585], [`def f[T]`, `class C[T]`][PEP 695]\n| Pattern Matching | [`match`][Pattern Syntax] | [`match`][PEP 634]\n| Anonymous Function | [`\\|x\\| { x + 1 }`][Closure] | [`lambda x: x + 1`][Lambda]\n| Foreign Function Interface | [FFI][Rust FFI] | [CFFI][CFFI]\n\n[trait]: https://doc.rust-lang.org/book/ch10-02-traits.html\n[Protocol]: https://docs.python.org/3/library/typing.html#typing.Protocol\n[Rust Generic]: https://doc.rust-lang.org/book/ch10-01-syntax.html\n[PEP 585]: https://peps.python.org/pep-0585/\n[PEP 695]: https://peps.python.org/pep-0695/\n[Pattern Syntax]: https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html\n[PEP 634]: https://peps.python.org/pep-0634/\n[Closure]: https://doc.rust-lang.org/book/ch13-01-closures.html\n[Lambda]: https://docs.python.org/3/reference/expressions.html#lambda\n[Rust FFI]: https://doc.rust-lang.org/nomicon/ffi.html\n[CFFI]: https://cffi.readthedocs.io/en/latest/\n\n# Data Structures\n\n| Data Structure | Rust | Python\n| - | - | -\n| Data Type | [`struct`][struct] | [`@dataclass`][dataclass]\n| Algebraic Data Type | [`enum`][enum] | [`Enum`][Enum], [`Union` of `dataclass`][union-dataclass]\n| Result | [`Result`][Result] | [`returns.Result`][returns Result]\n| Optional | [`Option`][Option] | [`T \\| None`][Optional], [`returns.Maybe`][Maybe]\n| Fixed-sized Numerics | [`u8`, `u16`, etc.][Rust Data Types] | [NumPy Data Types][NumPy Data Types]\n\n[struct]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html\n[dataclass]: https://docs.python.org/3/library/dataclasses.html\n[enum]: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html\n[Enum]: https://docs.python.org/3/library/enum.html\n[union-dataclass]: https://stackoverflow.com/a/71519690\n[Result]: https://doc.rust-lang.org/std/result/\n[returns Result]: https://returns.readthedocs.io/en/latest/pages/result.html\n[Option]: https://doc.rust-lang.org/std/option/\n[Optional]: https://docs.python.org/3/library/typing.html#typing.Optional\n[Maybe]: https://returns.readthedocs.io/en/latest/pages/maybe.html\n[Rust Data Types]: https://doc.rust-lang.org/book/ch03-02-data-types.html\n[NumPy Data Types]: https://numpy.org/doc/stable/user/basics.types.html\n\n# Rust/Python Interop\n\n- [PyO3](https://pyo3.rs/)\n\n# Popular Python Packages Implemented in Rust\n\n- [Ruff][Ruff]\n- [uv][uv]\n- [Pydantic][Pydantic]\n- [cryptography][cryptography]\n- [Polars][Polars]\n- [RustPython - A Python interpretter written in Rust][RustPython]\n\n[Pydantic]: https://github.com/pydantic/pydantic\n[cryptography]: https://github.com/pyca/cryptography\n[Polars]: https://github.com/pola-rs/polars\n[RustPython]: https://github.com/RustPython/RustPython\n\n# Misc Rust and Python Similarities\n\n- Both languages prefer `snake_case` naming over `lowerCamelCase`\n- Both languages use suffix type syntax (e.g. `x: int` / `x: i32`)\n- Neither language is controlled by a single company\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnthagen%2Frust-to-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnthagen%2Frust-to-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnthagen%2Frust-to-python/lists"}