Open
Conversation
Member
Wentzell
commented
Jun 20, 2020
- For c2py of stl types take argument by value and move elements
- Convert any std::vector and std::array<T, R> to a numpy array
parcollet
reviewed
Jun 22, 2020
c++/cpp2py/converters/vector.hpp
Outdated
|
|
||
| template <typename T> static void delete_pycapsule(PyObject *capsule) { | ||
| auto *ptr = static_cast<std::unique_ptr<T[]> *>(PyCapsule_GetPointer(capsule, "guard")); | ||
| auto *ptr = static_cast<T *>(PyCapsule_GetPointer(capsule, "guard")); |
Member
There was a problem hiding this comment.
Move the deleter in general cpp2py file
Member
Author
There was a problem hiding this comment.
How about we just do
auto delete_pycapsule = [](PyObject *capsule) {
auto *ptr = static_cast<std::vector<T> *>(PyCapsule_GetPointer(capsule, "guard"));
delete ptr;
};
PyObject * capsule = PyCapsule_New(vec_heap, "guard", delete_pycapsule);right where we need it?
| std::copy(data, data + size, begin(v)); | ||
|
|
||
| if (p.element_type == npy_type<pyref>) { | ||
| auto **data = static_cast<PyObject **>(p.data); |
Member
Author
There was a problem hiding this comment.
Which previous comment are you referring to?
Member
Author
|
@parcollet By taking |
e6da84e to
ae0db29
Compare
ae0db29 to
c9932ee
Compare
c9932ee to
80ec453
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.