Skip to content
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

Using Pybind11 to wrap NESTKernel #3185

Open
med-ayssar opened this issue Apr 19, 2024 · 0 comments
Open

Using Pybind11 to wrap NESTKernel #3185

med-ayssar opened this issue Apr 19, 2024 · 0 comments
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Enhancement New functionality, model or documentation
Projects

Comments

@med-ayssar
Copy link
Contributor

Is your feature request related to a problem? Please describe.

  • PyNEST uses the SLIEngine API to communicate with the C++ code, and removing this intermediate interface might have huge consquences for the interface design between C++ and Python.
  • For each exported class from C++ to Python, a Wrapper class in required to encapsulate the C++ implemention and redirect to the correct function, and sli_pop, sli_push and sli_run, all those help functions must be replaced and might require alot of efforts.

Describe the solution you'd like
Pybind: provides an interesting interface to handle the binding between both languages, without to manually implement a Wrapper for the export class.

Example

From the Pybind documentation

#include <pybind11/pybind11.h>

namespace py = pybind11;

struct Pet {
    Pet(const std::string &name) : name(name) { }
    void setName(const std::string &name_) { name = name_; }
    const std::string &getName() const { return name; }

    std::string name;
};

PYBIND11_MODULE(example, m) {
    py::class_<Pet>(m, "Pet")
        .def(py::init<const std::string &>())
        .def("setName", &Pet::setName)
        .def("getName", &Pet::getName);
}

Just like that, we will have the Pet class also available in python in the exmaple module.

import example
p = example.Pet("RandomName")
@gtrensch gtrensch added this to To do in PyNEST via automation May 17, 2024
@gtrensch gtrensch added T: Enhancement New functionality, model or documentation S: Normal Handle this with default priority I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Enhancement New functionality, model or documentation
Projects
PyNEST
  
To do
Development

No branches or pull requests

2 participants