Skip to content

Commit 9d3a8f9

Browse files
committed
WIP
1 parent 0c8ba1e commit 9d3a8f9

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

README_smart_holder.rst

+47-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Overview
3333
What is fundamentally different?
3434
--------------------------------
3535

36-
- Traditional pybind11 has the concept of "smart-pointer is holder".
36+
- Classic pybind11 has the concept of "smart-pointer is holder".
3737
Interoperability between smart-pointers is completely missing. For
3838
example, when using ``std::shared_ptr`` as holder, ``return``-ing
3939
a ``std::unique_ptr`` leads to undefined runtime behavior
@@ -101,7 +101,7 @@ holder:
101101
py::classh<Foo>(m, "Foo");
102102
}
103103
104-
There are three small differences compared to traditional pybind11:
104+
There are three small differences compared to classic pybind11:
105105

106106
- ``#include <pybind11/smart_holder.h>`` is used instead of
107107
``#include <pybind11/pybind11.h>``.
@@ -175,6 +175,49 @@ still being able to build the same code with classic pybind11. Please see
175175
tests/test_classh_mock.cpp for an example.
176176

177177

178+
Classic / conservative / progressive cross-module compatibility
179+
---------------------------------------------------------------
180+
181+
Currently there are essentially three modes for building a pybind11 extension module:
182+
183+
* Classic: pybind11 stable (e.g. v2.6.2) or current master
184+
* Conservative: pybind11 smart_holder
185+
* Progressive: pybind11 smart_holder with ``-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT``
186+
187+
In environments that mix modules built with different modes, this is the compatibility
188+
matrix for ``py::class_``-wrapped types:
189+
190+
.. list-table:: Compatibility matrix
191+
:widths: auto
192+
:header-rows: 2
193+
194+
* -
195+
-
196+
-
197+
- Module 2
198+
-
199+
* -
200+
-
201+
- Classic
202+
- Conservative
203+
- Progressive
204+
* -
205+
- **Classic**
206+
- full
207+
- one-way
208+
- isolated
209+
* - **Module 1**
210+
- **Conservative**
211+
- one-way
212+
- full
213+
- isolated
214+
* -
215+
- **Progressive**
216+
- isolated
217+
- isolated
218+
- full
219+
220+
178221
Trampolines and std::unique_ptr
179222
-------------------------------
180223

@@ -191,7 +234,7 @@ inherit from ``py::trampoline_self_life_support``, for example:
191234
...
192235
};
193236
194-
This is the only difference compared to traditional pybind11. A fairly
237+
This is the only difference compared to classic pybind11. A fairly
195238
minimal but complete example is tests/test_class_sh_trampoline_unique_ptr.cpp.
196239

197240

@@ -200,7 +243,7 @@ Ideas for the long-term
200243

201244
The macros are clearly an inconvenience in many situations. Highly
202245
speculative: to avoid the need for the macros, a potential approach would
203-
be to combine the traditional implementation (``type_caster_base``) with
246+
be to combine the classic implementation (``type_caster_base``) with
204247
the ``smart_holder_type_caster``, but this will probably be very messy and
205248
not great as a long-term solution. The ``type_caster_base`` code is very
206249
complex already. A more maintainable approach long-term could be to work

include/pybind11/detail/internals.h

+2
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ struct type_info {
154154
#ifndef PYBIND11_USE_SMART_HOLDER_AS_DEFAULT
155155
#define PYBIND11_INTERNALS_VERSION 4
156156
#else
157+
// See README_smart_holder.rst:
158+
// Classic / conservative / progressive cross-module compatibility
157159
#define PYBIND11_INTERNALS_VERSION 1004
158160
#endif
159161

0 commit comments

Comments
 (0)