-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide comparison between PyO3 and rust-cpython #55
Comments
at this point, base concepts, compared to rust-cpython, are totally different.
rust-cpython: impl PyList {
fn new(py: Python) -> PyList {...}
fn get_item(&self, py: Python, index: isize) -> PyObject {...}
} pyo3: impl PyList {
fn new(py: Python) -> &PyList {...}
fn get_item(&self, index: isize) -> &PyObject {...}
} Because pyo3 allows only references to python object, all refs uses Gil lifetime. So |
|
motivation
downsides:
|
In that case, definitely something I'll be switching over to once it's possible to resolve #5. |
I used rust-cpython, and had occasional segfaults. never got any response from author. |
In that case, once I've finished migrating as much of my project to the Rust side as possible, if I encounter segfaults and can't resolve them, maybe I'll drop to something lower-level like Snaek. ...or just port everything back to pure Python. Avoiding dependency on nightly Rust is non-negotiable. |
I hope proc_macro will be stabilized by the end of year. |
Just landed pretty big change.
for example: use pyo3::*;
fn parse_int(s: String) -> PyResult<usize> {
Ok(s.parse::<usize>()?)
} The code snippet above will raise |
closing, there is link in readme |
Does rust_cpytho support all Python packages like socket? |
@MajidHeydari I don't see why it wouldn't. There are two major reasons something might not support a Python package:
The former isn't a problem because rust-cpython embeds or produces compiled extensions for the actual CPython. As for the latter, rust-cpython won't cause incompatibilities, but it's still up to you to avoid using Python extensions and Rust crates which depend on incompatible C libraries at the same time. (eg. Trying to use both the Python and Rust bindings for the same C library in the same process, rather than using just one and using rust-cpython to share it across the language barrier.) |
can rust_cpytho build web framework ? |
To what end? Combining Python with another language isn't going to magically make it faster because the things holding back Python's speed are inherent and changing them would break compatibility with existing Python packages. You can use rust-cpython to write compiled modules for a Python web framework to load, but things like Python's Global Interpreter Lock and highly dynamic nature aren't going to perform well if you try to write a web framework by embedding a Python runtime into Rust. (And, if you've got CPU-bound tasks in your web app, you're supposed to move them out into something like Celery anyway so they don't block the part of the app handling the web requests.) |
Does webassembly not make the server faster? |
WebAssembly isn't magic sauce. You need to use it to replace the bits that are slow... and if all the low-hanging fruit has been picked and the remaining slowness is spread throughout the language because of things like extremely dynamic dispatch, then you can't really "replace" it without rewriting everything in another language. |
When I come to the PyO3 frontpage, having never seen PyO3 before, my first questions are "how is this different from rust-cpython?" and "Why would I want to use this instead?"
So far, all I've been able to determine is:
ToPyObject
impl
s being this long in rust-cpython.It'd be a good idea to add a blurb to the README explaining:
The text was updated successfully, but these errors were encountered: