Skip to content

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

Closed
@Dalaba

Description

@Dalaba

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions