Skip to content

why pybind11 is slower than Python and boost python; the benchmark does not include performance test? #1825

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

Closed
Dalaba opened this issue Jul 2, 2019 · 2 comments

Comments

@Dalaba
Copy link

Dalaba commented Jul 2, 2019

pybind11 example:
#include<pybind11/pybind11.h>
namespace py = pybind11;
int test(int t) {
return t * t;
}
PYBIND11_MODULE(pybindexample, m) {
m.def("testFunc", &test);
}
then export as .pyc

Python example:
from pybindexample import testFunc
def pytestFunc(arg):
return arg * arg

final results:
t1 = timeit.Timer('pytestFunc(10)', 'from main import pytestFunc')
print t1.timeit()
t1 = 0.07

t2 = timeit.Timer('testFunc(10)', 'from main import testFunc')
print t2.timeit()
t2 = 0.26

@molpopgen
Copy link

This is a duplicate of #1227. Take a look there.

@YannickJadoul
Copy link
Collaborator

Thanks for answering this, @molpopgen!

I don't see a Boost.Python example, so I can't compare if pybind11 is slower.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants