-
Notifications
You must be signed in to change notification settings - Fork 2.2k
why pybind11 is slower than cython #1227
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
Comments
IIRC, due to all the argument conversion and casting logic in pybind11, Cython will normally be somewhat faster on microbenchmarks which is to be expected. // Make sure you compile both with the same compiler flags though for the results to be any meaningful. |
it allocate a std::vector.reserve to store the function argument for each call, which will do malloc/new memory allocation, but it's meaningless |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
simple benchmark for the example
add()
functionrelease buidl (using
cmake -DCMAKE_BUILD_TYPE=Release ..
) improves the speed:however, comparing with cython it still not fast enough:
pybind11 is 4X times slower than cython.
Why that happened? Is there anything to do to improve the performance here?
The text was updated successfully, but these errors were encountered: