Rust + Python = ????
Rust C
Switch branches/tags
Nothing to show
Clone or download
Latest commit edbe18c Mar 21, 2016
Failed to load latest commit information.
src fix object safety error in FromPyType trait Mar 19, 2016
.gitignore updated git ignore Aug 24, 2014
.travis.yml travis Oct 16, 2014
Cargo.toml Update to rust 1.0.0 stable Jun 24, 2015 Update Jan 27, 2015 Update to rust 1.0.0 stable Jun 24, 2015


A simple library to allow for easy use of python from rust.


Currently this library has not received much love (pull requests welcome for any interested) and does not build with rust 1.0.

For another library that also strives to bridge the gap between python and rust and might be a little more up to day see:

How to Use

This library is meant to be middle ware for users wanting to use python libraries from rust. It allows users to quickly use existing tools and get working on interesting things fast!

See for an example of how to bind enough smtplib to send emails.

For more documentation, run rustdoc src/ and look at doc/rustpy/index.html. Pull requests are welcome!

extern crate rustpy;
use rustpy::{ToPyType, FromPyType, PyState};

fn main() {
  let py = PyState::new();
  let module = py.get_module("math").unwrap();
  let func = module.get_func("sqrt").unwrap();
  let args = (144f32, ).to_py_object(&py).unwrap();
  let untyped_res =;
  let result = py.from_py_object::<f32>(untyped_res).unwrap();
  assert_eq!(result, 12f32);

Important note: Only create one instance of PyState at a time. On construction, it grabs a global lock to prevent more than one thread from interacting with the interpreter thus making it very easy to deadlock.