Type Buffer's flags argument#648
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #648 +/- ##
=======================================
Coverage 99.88% 99.88%
=======================================
Files 62 62
Lines 2723 2723
=======================================
Hits 2720 2720
Misses 3 3 |
| def __cinit__(self, obj, int flags): | ||
| PyObject_GetBuffer(obj, &(self.buffer), flags) |
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
|
Thanks David! 🙏 |
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: