Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine conditions under which
ndarray_wrap
copies
The ndarray caster uses return value policies to decide when to copy its input, which can lead to bogus results due to a cascade of issues (see issue #188 for a discussion). The preceding commits address many of the issues regarding return value policies. This commit adds one more refinement: it adds an interpretation of several standard return value policies: - ``nb::rv_policy::automatic`` copies when an nd-array has no owner and is not already associated with a Python object. - ``nb::rv_policy::automatic_reference`` and ``nb::rv_policy::reference`` never copy. - ``nb::rv_policy::copy`` always copies. - ``nb::rv_policy::none`` refuses the cast unless the array is already associated with an existing Python object (e.g. a NumPy array), in which case that object is returned. - ``nb::rv_policy::reference_internal`` retroactively sets the ndarray's ``owner`` field to the method's ``self`` argument. It fails with an error if there is already an owner. - ``nb::rv_policy::move`` is not supported.
- Loading branch information
Showing
6 changed files
with
219 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cleanup may be nullptr.