Repository navigation
Call functions written in Rust - #23
Merged
Merged
Conversation
… function, as nanobind's def adds one of C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A plain function of Rust, of the generated structs, is called from Python as a
@native_function: as one of C++ is.dataclass_native::python::function(extension, "name", f)adds it to the extension, as nanobind'sdefdoes one of C++. It is of up to 8 arguments, each of which, and what it gives, is a type which a field may be of, converted as a field is.pkg._native, as a class of pyo3 is of the extension it is built in: so that is what its@native_functionnames.Sharedor aHeldof it, which is not. What is given is not copied.Resultit gives is raised if it is an error: as aValueError, if not an exception of pyo3's. An argument it cannot take is aTypeError, "incompatible function arguments", as nanobind's is.The tests of functions which are run with the C++ extensions are now run with that of Rust too, against the same functions written in Rust (
tests/rust/functions.rs). Those are declared as ofschemas._functions, so the test's copy of the package has a_functions.pywhich gives those of_nativeas that. A new test declares functions ofschemas._nativeitself.Of what Rust is yet to do, this leaves msgpack, JSON and Arrow, the descriptors of fields, and an example built with maturin.