-
-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
Not affiliated with hyperjson but just my opinion: I have not found the needless_pass_by_value lint to be valuable and always just disable it in my projects when it comes up. #![allow(clippy::needless_pass_by_value)] In this case |
The elimination of |
If something is already a pointer (like PyObject) then sticking it behind another pointer is likely to make things slower, not faster. See for example https://rust.godbolt.org/z/R7NKYZ in which the |
Looking at the godbolt link I lean towards what @dtolnay says. @ZapAnton, could you try adding the clippy setting and revert the references?
Hum? I see it being used here: https://pyo3.rs/v0.5.0/
I think Would be interested in benchmarking PyObject vs PyObjectRef, though. |
Meanwhile I opened rust-lang/rust-clippy#3439 to disable that needless_pass_by_value lint by default in Clippy. |
pyfn and pyfunction use the same code generation backend, so it's unlikely the cause. |
@konstin, do you think that testing |
I've actually no idea how they compare regarding performance |
This PR tries to reduce the warning-noise when
cargo clippy
is applied.The most common warning was about passing arguments by value instead of passing by reference:
Some of the warnings I managed to resolve, but for functions annotated with
#[pyfunction]
the simple usage of&Option<>
introduces an error:The way to resolve the error could be the usage the
PyObjectRef
and also the usage of#[pyfn()]
instead of#[pyfunction]
(actually could not find#[pyfunction]
in the0.5.0
documentation - could it be deprecated?), but that would introduce the API breakage, so I left it for now.The result changes are somewhat chaotic, so feel free to close