{{ message }}
Type Buffer's flags argument#648
Merged
Merged
Conversation
jakirkham
commented
Nov 18, 2024
Comment on lines
+15
to
16
| def __cinit__(self, obj, int flags): | ||
| PyObject_GetBuffer(obj, &(self.buffer), flags) |
Member
Author
There was a problem hiding this comment.
The flags argument here is only used in this PyObject_GetBuffer call. The signature of this function in Cython or in Python is
int PyObject_GetBuffer(object obj, Py_buffer *view, int flags)Here flags is an int specified by a range of possible constants to provide a specific kind of Py_buffer object
To make sure that flags can be passed through unaltered to this function call, this types the __cinit__ arguments to match
Without this typing, Cython will convert values to Python objects first and then convert them back in this constructor (a needless exercise). This change will fix that issue going forward
dstansby
approved these changes
Nov 18, 2024
Member
Author
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.

Ensure the
flagsargument inBufferis correctly typed so it can be passed verbatim toPyObject_GetBuffer. This can also avoid needless conversions to and from Pythonobjecttype.TODO: