Comments (5)
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.
I am closing this issue as #269 has been merged. Thanks @lyskov !
from binder.
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.
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.
@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)
- ImportError when importing two different packages generated with binder that share an overlap HOT 8
- Release? HOT 6
- [question] customization of a trampoline function definition HOT 5
- Unclear usage of `add_on_binder` HOT 14
- Is there a way to exclude an enum? HOT 2
- Non-portable generated code for `size_t` HOT 18
- Build script tries to use pybind11 commit that isn't on a branch (anymore?) HOT 1
- Modify reference to primitive type HOT 2
- Method parameter reference to primitive type not working HOT 1
- LLVM >= 16.0.6 no longer builds with --std=c++14 HOT 4
- build-and-run-tests.py: Missing positional argument in call to install_llvm_tool HOT 1
- bind.py: upgrade llvm version HOT 3
- Potential new release? HOT 3
- Building against LLVM with `LLVM_BUILD_LLVM_DYLIB=OFF` HOT 2
- std::nullptr_t replacement to std::std::nullptr_t HOT 6
- Release 1.4.1 or 1.4.2? HOT 3
- Config option to rename namespace (or join it contents with some other namespace, even global) HOT 3
- FTBFS for LLVM 18 HOT 1
- Wrong code for MSVC HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binder.