Modern packages for python, for which efficiency is pivotal, tend not to be written in python, but rather compiled languages such as c++, rust, zig, etc. Notable examples include the widely used packages numpy, pydantic, polars, as well as pydust. Once written in these languages, particular tools are applied to obtain bindings for higher level language such as python.
In the case of Rust, maturin can be utilised for this purpose.
In this repository, we provide an example of this.
The python package created is written in Rust and provides a few simple classes
for recursive structures that occur in BIM models known as Psets.
To achieve this, we use PyO3 (currently v0.25),
rely on rust's serde package to parse arbitrary JSON-like objects,
and develop a few simple pure rust structs/traits to handle tree structures.
- rust (currently uses
v1.87) incl. cargo - python3 (development was performed primarily with
v3.13, but this should work with all versions afterv3.10) - bash
- the justfile tool
Create files from templates
just setupAdjust the newly created .env file. Then run
just build # to install dependencies, compile the code, build the bindings
just build-bindings # to just build the bindingsQA tasks are as follows
just prettify # to check and perform linting
just tests-unit # to run unit tests
just test-unit {path/to/[tests_]file.rs}
just test-unit-optimised # to run with code optimised for architecture set in .env
just test-unit-optimised {path/to/[tests_]file.rs}-
No references to personal or company data is contained in this repository.
-
The here presented code was written entirely by the owner of the repository and account, in the context of other private repositories.
-
None of the source code (rust), stubs (python), configuration files / task scripts (.gitignore, toml files, justfile etc.), or documents (e.g. this README.md file), were generated via LLMs. Nor have they been lifted from other people's work.