Giter Site home page Giter Site logo

Comments (5)

kliegeois avatar kliegeois commented on June 8, 2024 1

Thanks for your comment @lyskov !
I will start working on this and will ping you on the PR once it is ready for review.

from binder.

kliegeois avatar kliegeois commented on June 8, 2024 1

I am closing this issue as #269 has been merged. Thanks @lyskov !

from binder.

lyskov avatar lyskov commented on June 8, 2024

I am open to the idea assuming that switching logic could be implemented neatly so it does not make code much harder to maintain. Do you already know what kind of changes in generated code this command-line will trigger? If so, could you please outline them here so it is possible to look at the concrete example? Thanks.

from binder.

kliegeois avatar kliegeois commented on June 8, 2024

Thanks @lyskov for your comments!

(This issue pybind/pybind11#2839 is a good extra context of why it could be useful)

Up to now, I have been using the conservative mode of the smart holder branch.

So the code:

#include <pybind11/pybind11.h>

struct Foo {};

PYBIND11_MODULE(example_bindings, m) {
    namespace py = pybind11;
    py::class_<Foo>(m, "Foo");
}

would now be replaced by:

#include <pybind11/smart_holder.h>

struct Foo {};

PYBIND11_SMART_HOLDER_TYPE_CASTERS(Foo)

PYBIND11_MODULE(example_bindings, m) {
    namespace py = pybind11;
    py::classh<Foo>(m, "Foo");
}

In my previous successful tests, I have been using py::classh and PYBIND11_SMART_HOLDER_TYPE_CASTERS only for the classes for which it was useful.

Concretely, for binder, I was thinking of adding a configuration option that can be enabled per class like this:

+use_smart_holder_for_class Foo

If the option is set, then we would add PYBIND11_SMART_HOLDER_TYPE_CASTERS and use py::classh for that class.
And if there is at least one use_smart_holder_for_class, we would use #include <pybind11/smart_holder.h> instead of #include <pybind11/pybind11.h>.

What do you think of this?

from binder.

lyskov avatar lyskov commented on June 8, 2024

@kliegeois this looks quite reasonable to me, pull-request implementing this will be welcome! Could you please also include test in your PR? If so please take a look at https://github.com/RosettaCommons/binder/blob/master/test/T81.custom_trampoline_with_args.config test on how to specify specific config directive for particular test. Thanks,

Also, thank you for mentioning pybind/pybind11#2839 issue! I noticed similar issue in my project and having general solution for them would great!

from binder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.