Neat. Was able to clone the repo, run cargo run, and drop into a python shell. Doesn't seem like can do much right now, but I really like the idea.
>>>>> a = [1,2,3]
>>>>> a[2:]
[3]
>>>>> a[1:]
[2, 3]
>>>>> fh = open('~/.ssh/id_rsa.pub', 'r')
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: RefCell { value: [PyObj instance] }', src/libcore/result.rs:999:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
What would be really cool if this could one day be like Nuitka- but in rust. Write in python, compile into Rust. Maybe even support inline Rust like cPython supports inline C.> cPython supports inline C
First time I am hearing this. Can you share an example?
https://cffi.readthedocs.io/en/latest/ & https://docs.python.org/3/extending/extending.html
There also is https://github.com/rochacbruno/rust-python-example which is something I want to look into.
As for an example, I'm using Snappy right now, so here you go: https://github.com/andrix/python-snappy/blob/master/snappy/s... & https://github.com/andrix/python-snappy/blob/master/snappy/s...
It still requires you to compile the C part- which is why sometimes you need GCC when you're doing a pip install.
I’ve done a lot of interfacing with C and C++. pybind11 [0] has been the easiest and most effective for me to use. It targets C++, but it’s easy enough to wrap C code with it. Cython brings along a lot more bookkeeping code and overhead in my experience. cffi isn’t bad, but it’s not as flexible/expressive.