-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add a pybind function to clear a list. #5153
Conversation
It seems that this is a system/test configuration/version issue rather than an issue with the CL per se. Could a maintainer have a look? Tthat would be awesome! Thank you very much in advance! Using cmake version 3.29.4 |
About to close/reopen this PR to trigger a fresh rerun of the GitHub Actions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think this is a useful small addition, especially because the implementation isn't exactly obvious (why is there no PyList_Clear()
?).
include/pybind11/pytypes.h
Outdated
@@ -2183,6 +2183,11 @@ class list : public object { | |||
throw error_already_set(); | |||
} | |||
} | |||
void clear() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the non-const comment the other pybind11 clear methods have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for catching this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for the comment issue, looks good.
Description
Add
py::list::clear()
.See also: https://stackoverflow.com/questions/23489177/how-to-clear-a-pylistobject
Suggested changelog entry: