Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
717df752
Commit
717df752
authored
Jun 28, 2016
by
nafur
Committed by
GitHub
Jun 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added warning about same-address-optimization
See
https://github.com/pybind/pybind11/issues/254
parent
2353b9b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletions
+10
-1
docs/advanced.rst
+10
-1
No files found.
docs/advanced.rst
View file @
717df752
...
...
@@ -468,7 +468,7 @@ functions. The default policy is :enum:`return_value_policy::automatic`.
| :enum:`return_value_policy::take_ownership` | Reference an existing object (i.e. do not create a new copy) and take |
| | ownership. Python will call the destructor and delete operator when the |
| | object's reference count reaches zero. Undefined behavior ensues when the |
| | C++ side does the same.
.
|
| | C++ side does the same. |
+--------------------------------------------------+----------------------------------------------------------------------------+
| :enum:`return_value_policy::copy` | Create a new copy of the returned object, which will be owned by Python. |
| | This policy is comparably safe because the lifetimes of the two instances |
...
...
@@ -526,6 +526,15 @@ The following example snippet shows a use case of the
non-determinism and segmentation faults, hence it is worth spending the
time to understand all the different options in the table above.
.. warning::
pybind11 tries to eliminate duplicate addresses by returning the same reference object.
If two addresses are the same, though they do not point to the same object semantically,
this may cause unexpected behaviour. An explicit policy should be used instead of
relying on `automatic`.
A common example is a reference to the first member of a class which has the same memory
location as its owning class.
.. note::
The next section on :ref:`call_policies` discusses *call policies* that can be
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment