@@ -159,95 +159,95 @@ Buffer related functions
159159
160160 The following table gives possible values to the *flags * arguments.
161161
162- +------------------------------+-----------------------------------------------+
163- | Flag | Description |
164- +==============================+===============================================+
165- | :cmacro: `PyBUF_SIMPLE ` |This is the default flag state. The returned |
166- | |buffer may or may not have writable memory. |
167- | |The format will be assumed to be unsigned bytes |
168- | |. This is a "stand-alone" flag constant. It |
169- | |never needs to be |'d to the others. The |
170- | |exporter will raise an error if it cannot |
171- | |provide such a contiguous buffer of bytes. |
172- | | |
173- +------------------------------+-----------------------------------------------+
174- | :cmacro: `PyBUF_WRITABLE ` |The returned buffer must be writable. If it is |
175- | |not writable, then raise an error. |
176- +------------------------------+-----------------------------------------------+
177- | :cmacro: `PyBUF_STRIDES ` |This implies :cmacro:`PyBUF_ND`. The returned |
178- | |buffer must provide strides information |
179- | |(i.e. the strides cannot be NULL). This would |
180- | |be used when the consumer can handle strided, |
181- | |discontiguous arrays. Handling strides |
182- | |automatically assumes you can handle shape. The|
183- | |exporter may raise an error if cannot provide a |
184- | |strided-only representation of the data |
185- | |(i.e. without the suboffsets). |
186- +------------------------------+-----------------------------------------------+
187- | :cmacro: `PyBUF_ND ` |The returned buffer must provide shape |
188- | |information. The memory will be assumed C-style|
189- | |contiguous (last dimension varies the |
190- | |fastest). The exporter may raise an error if it|
191- | |cannot provide this kind of contiguous |
192- | |buffer. If this is not given then shape will be|
193- | |*NULL*. |
194- | | |
195- | | |
196- +------------------------------+-----------------------------------------------+
197- | :cmacro:`PyBUF_C_CONTIGUOUS ` |These flags indicate that the contiguoity |
198- | :cmacro:`PyBUF_F_CONTIGUOUS ` |returned buffer must be respectively, |
199- | :cmacro:`PyBUF_ANY_CONTIGUOUS`|C-contiguous (last dimension varies the |
200- | |fastest), Fortran contiguous (first dimension |
201- | |varies the fastest) or either one. All of |
202- | |these flags imply :cmacro:`PyBUF_STRIDES` and |
203- | |guarantee that the strides buffer info |
204- | |structure will be filled in correctly. |
205- | | |
206- +------------------------------+-----------------------------------------------+
207- | :cmacro: `PyBUF_INDIRECT ` |This implies :cmacro:`PyBUF_STRIDES`. The |
208- | |returned buffer must have suboffsets |
209- | |information (which can be NULL if no suboffsets |
210- | |are needed). This would be used when the |
211- | |consumer can handle indirect array referencing |
212- | |implied by these suboffsets. |
213- | | |
214- | | |
215- | | |
216- +------------------------------+-----------------------------------------------+
217- | :cmacro: `PyBUF_FORMAT ` |The returned buffer must have true format |
218- | |information if this flag is provided. This |
219- | |would be used when the consumer is going to be |
220- | |checking for what 'kind' of data is actually |
221- | |stored. An exporter should always be able to |
222- | |provide this information if requested. If |
223- | |format is not explicitly requested then the |
224- | |format must be returned as *NULL* (which means |
225- | |``'B'``, or unsigned bytes) |
226- +------------------------------+-----------------------------------------------+
227- | :cmacro: `PyBUF_STRIDED ` |This is equivalent to ``(PyBUF_STRIDES | |
228- | |PyBUF_WRITABLE)``. |
229- +------------------------------+-----------------------------------------------+
230- | :cmacro: `PyBUF_STRIDED_RO ` |This is equivalent to ``(PyBUF_STRIDES)``. |
231- | | |
232- +------------------------------+-----------------------------------------------+
233- | :cmacro: `PyBUF_RECORDS ` |This is equivalent to ``(PyBUF_STRIDES | |
234- | |PyBUF_FORMAT | PyBUF_WRITABLE)``. |
235- +------------------------------+-----------------------------------------------+
236- | :cmacro: `PyBUF_RECORDS_RO ` |This is equivalent to ``(PyBUF_STRIDES | |
237- | |PyBUF_FORMAT)``. |
238- +------------------------------+-----------------------------------------------+
239- | :cmacro: `PyBUF_FULL ` |This is equivalent to ``(PyBUF_INDIRECT | |
240- | |PyBUF_FORMAT | PyBUF_WRITABLE)``. |
241- +------------------------------+-----------------------------------------------+
242- | :cmacro: `PyBUF_FULL_RO` ` |This is equivalent to ``(PyBUF_INDIRECT | |
243- | |PyBUF_FORMAT)``. |
244- +------------------------------+-----------------------------------------------+
245- | :cmacro: `PyBUF_CONTIG ` |This is equivalent to ``(PyBUF_ND | |
246- | |PyBUF_WRITABLE)``. |
247- +------------------------------+-----------------------------------------------+
248- | :cmacro: `PyBUF_CONTIG_RO ` |This is equivalent to ``(PyBUF_ND)``. |
249- | | |
250- +------------------------------+-----------------------------------------------+
162+ +------------------------------+--------------------------------------------------- +
163+ | Flag | Description |
164+ +==============================+=================================================== +
165+ | :cmacro: `PyBUF_SIMPLE ` | This is the default flag state. The returned |
166+ | | buffer may or may not have writable memory. The |
167+ | | format of the data will be assumed to be unsigned |
168+ | | bytes . This is a "stand-alone" flag constant. It |
169+ | | never needs to be ' |'d to the others. The exporter |
170+ | | will raise an error if it cannot provide such a |
171+ | | contiguous buffer of bytes. |
172+ | | |
173+ +------------------------------+--------------------------------------------------- +
174+ | :cmacro: `PyBUF_WRITABLE ` | The returned buffer must be writable. If it is |
175+ | | not writable, then raise an error. |
176+ +------------------------------+--------------------------------------------------- +
177+ | :cmacro: `PyBUF_STRIDES ` | This implies :cmacro: `PyBUF_ND `. The returned |
178+ | | buffer must provide strides information (i.e. the |
179+ | | strides cannot be NULL). This would be used when |
180+ | | the consumer can handle strided, discontiguous |
181+ | | arrays. Handling strides automatically assumes |
182+ | | you can handle shape. The exporter can raise an |
183+ | | error if a strided representation of the data is |
184+ | | not possible (i.e. without the suboffsets). |
185+ | | |
186+ +------------------------------+--------------------------------------------------- +
187+ | :cmacro: `PyBUF_ND ` | The returned buffer must provide shape |
188+ | | information. The memory will be assumed C-style |
189+ | | contiguous (last dimension varies the |
190+ | | fastest). The exporter may raise an error if it |
191+ | | cannot provide this kind of contiguous buffer. If |
192+ | | this is not given then shape will be * NULL *. |
193+ | | |
194+ | | |
195+ | | |
196+ +------------------------------+--------------------------------------------------- +
197+ | :cmacro:`PyBUF_C_CONTIGUOUS ` | These flags indicate that the contiguity returned |
198+ | :cmacro:`PyBUF_F_CONTIGUOUS ` | buffer must be respectively, C-contiguous (last |
199+ | :cmacro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous |
200+ | | (first dimension varies the fastest) or either |
201+ | | one. All of these flags imply |
202+ | | :cmacro: `PyBUF_STRIDES ` and guarantee that the |
203+ | | strides buffer info structure will be filled in |
204+ | | correctly. |
205+ | | |
206+ +------------------------------+--------------------------------------------------- +
207+ | :cmacro: `PyBUF_INDIRECT ` | This flag indicates the returned buffer must have |
208+ | | suboffsets information (which can be NULL if no |
209+ | | suboffsets are needed). This can be used when |
210+ | | the consumer can handle indirect array |
211+ | | referencing implied by these suboffsets. This |
212+ | | implies :cmacro: ` PyBUF_STRIDES `. |
213+ | | |
214+ | | |
215+ | | |
216+ +------------------------------+--------------------------------------------------- +
217+ | :cmacro: `PyBUF_FORMAT ` | The returned buffer must have true format |
218+ | | information if this flag is provided. This would |
219+ | | be used when the consumer is going to be checking |
220+ | | for what 'kind' of data is actually stored. An |
221+ | | exporter should always be able to provide this |
222+ | | information if requested. If format is not |
223+ | | explicitly requested then the format must be |
224+ | | returned as *NULL * (which means `` 'B' ``, or |
225+ | | unsigned bytes) |
226+ +------------------------------+--------------------------------------------------- +
227+ | :cmacro: `PyBUF_STRIDED ` | This is equivalent to ``(PyBUF_STRIDES | |
228+ | | PyBUF_WRITABLE)``. |
229+ +------------------------------+--------------------------------------------------- +
230+ | :cmacro: `PyBUF_STRIDED_RO ` | This is equivalent to ``(PyBUF_STRIDES) ``. |
231+ | | |
232+ +------------------------------+--------------------------------------------------- +
233+ | :cmacro: `PyBUF_RECORDS ` | This is equivalent to ``(PyBUF_STRIDES | |
234+ | | PyBUF_FORMAT | PyBUF_WRITABLE)``. |
235+ +------------------------------+--------------------------------------------------- +
236+ | :cmacro: `PyBUF_RECORDS_RO ` | This is equivalent to ``(PyBUF_STRIDES | |
237+ | | PyBUF_FORMAT)``. |
238+ +------------------------------+--------------------------------------------------- +
239+ | :cmacro: `PyBUF_FULL ` | This is equivalent to ``(PyBUF_INDIRECT | |
240+ | | PyBUF_FORMAT | PyBUF_WRITABLE)``. |
241+ +------------------------------+--------------------------------------------------- +
242+ | :cmacro: `PyBUF_FULL_RO` ` | This is equivalent to ``(PyBUF_INDIRECT | |
243+ | | PyBUF_FORMAT)``. |
244+ +------------------------------+--------------------------------------------------- +
245+ | :cmacro: `PyBUF_CONTIG ` | This is equivalent to ``(PyBUF_ND | |
246+ | | PyBUF_WRITABLE)``. |
247+ +------------------------------+--------------------------------------------------- +
248+ | :cmacro: `PyBUF_CONTIG_RO ` | This is equivalent to ``(PyBUF_ND) ``. |
249+ | | |
250+ +------------------------------+--------------------------------------------------- +
251251
252252
253253.. cfunction :: void PyBuffer_Release(PyObject *obj, Py_buffer *view)
0 commit comments