Changeset 391 for python/trunk/Doc/c-api/buffer.rst
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Doc/c-api/buffer.rst
r2 r391 3 3 .. _bufferobjects: 4 4 5 Buffer Objects6 -------------- 5 Buffers and Memoryview Objects 6 ------------------------------ 7 7 8 8 .. sectionauthor:: Greg Stein <gstein@lyra.org> 9 .. sectionauthor:: Benjamin Peterson 9 10 10 11 … … 27 28 method. Any object that can export a series of bytes through the buffer 28 29 interface can be written to a file. There are a number of format codes to 29 :c func:`PyArg_ParseTuple` that operate against an object's buffer interface,30 :c:func:`PyArg_ParseTuple` that operate against an object's buffer interface, 30 31 returning data from the target object. 31 32 … … 33 34 objects and a C-level buffer API so that any built-in or used-defined type can 34 35 expose its characteristics. Both, however, have been deprecated because of 35 various shortcomings, and have been officially removed in Python 3 .0in favour36 various shortcomings, and have been officially removed in Python 3 in favour 36 37 of a new C-level buffer API and a new Python-level object named 37 38 :class:`memoryview`. … … 47 48 48 49 49 .. c type:: Py_buffer50 51 .. c member:: void *buf50 .. c:type:: Py_buffer 51 52 .. c:member:: void *buf 52 53 53 54 A pointer to the start of the memory for the object. 54 55 55 .. c member:: Py_ssize_t len56 .. c:member:: Py_ssize_t len 56 57 :noindex: 57 58 58 59 The total length of the memory in bytes. 59 60 60 .. c member:: int readonly61 .. c:member:: int readonly 61 62 62 63 An indicator of whether the buffer is read only. 63 64 64 .. c member:: const char *format65 .. c:member:: const char *format 65 66 :noindex: 66 67 … … 69 70 *NULL*, ``"B"`` (unsigned bytes) is assumed. 70 71 71 .. c member:: int ndim72 .. c:member:: int ndim 72 73 73 74 The number of dimensions the memory represents as a multi-dimensional 74 array. If it is 0, :c data:`strides` and :cdata:`suboffsets` must be75 array. If it is 0, :c:data:`strides` and :c:data:`suboffsets` must be 75 76 *NULL*. 76 77 77 .. c member:: Py_ssize_t *shape78 79 An array of :c type:`Py_ssize_t`\s the length of :cdata:`ndim` giving the78 .. c:member:: Py_ssize_t *shape 79 80 An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the 80 81 shape of the memory as a multi-dimensional array. Note that 81 82 ``((*shape)[0] * ... * (*shape)[ndims-1])*itemsize`` should be equal to 82 :c data:`len`.83 84 .. c member:: Py_ssize_t *strides85 86 An array of :c type:`Py_ssize_t`\s the length of :cdata:`ndim` giving the83 :c:data:`len`. 84 85 .. c:member:: Py_ssize_t *strides 86 87 An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim` giving the 87 88 number of bytes to skip to get to a new element in each dimension. 88 89 89 .. c member:: Py_ssize_t *suboffsets90 91 An array of :c type:`Py_ssize_t`\s the length of :cdata:`ndim`. If these90 .. c:member:: Py_ssize_t *suboffsets 91 92 An array of :c:type:`Py_ssize_t`\s the length of :c:data:`ndim`. If these 92 93 suboffset numbers are greater than or equal to 0, then the value stored 93 94 along the indicated dimension is a pointer and the suboffset value … … 114 115 115 116 116 .. c member:: Py_ssize_t itemsize117 .. c:member:: Py_ssize_t itemsize 117 118 118 119 This is a storage for the itemsize (in bytes) of each element of the 119 120 shared memory. It is technically un-necessary as it can be obtained 120 using :c func:`PyBuffer_SizeFromFormat`, however an exporter may know121 using :c:func:`PyBuffer_SizeFromFormat`, however an exporter may know 121 122 this information without parsing the format string and it is necessary 122 123 to know the itemsize for proper interpretation of striding. Therefore, 123 124 storing it is more convenient and faster. 124 125 125 .. c member:: void *internal126 .. c:member:: void *internal 126 127 127 128 This is for use internally by the exporting object. For example, this … … 136 137 137 138 138 .. c function:: int PyObject_CheckBuffer(PyObject *obj)139 .. c:function:: int PyObject_CheckBuffer(PyObject *obj) 139 140 140 141 Return 1 if *obj* supports the buffer interface otherwise 0. 141 142 142 143 143 .. c function:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)144 145 Export *obj* into a :c type:`Py_buffer`, *view*. These arguments must144 .. c:function:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags) 145 146 Export *obj* into a :c:type:`Py_buffer`, *view*. These arguments must 146 147 never be *NULL*. The *flags* argument is a bit field indicating what 147 148 kind of buffer the caller is prepared to deal with and therefore what … … 156 157 there is another error that is actually causing the problem. The 157 158 exporter can use flags information to simplify how much of the 158 :c data:`Py_buffer` structure is filled in with non-default values and/or159 :c:data:`Py_buffer` structure is filled in with non-default values and/or 159 160 raise an error if the object can't support a simpler view of its memory. 160 161 … … 163 164 The following table gives possible values to the *flags* arguments. 164 165 165 +------------------------------ +---------------------------------------------------+166 | Flag | Description |167 +============================== +===================================================+168 | :c macro:`PyBUF_SIMPLE` | This is the default flag state. The returned |169 | | buffer may or may not have writable memory. The |170 | | format of the data will be assumed to be unsigned |171 | | bytes. This is a "stand-alone" flag constant. It |172 | | never needs to be '|'d to the others. The exporter|173 | | will raise an error if it cannot provide such a |174 | | contiguous buffer of bytes. |175 | | |176 +------------------------------ +---------------------------------------------------+177 | :c macro:`PyBUF_WRITABLE` | The returned buffer must be writable. If it is |178 | | not writable, then raise an error. |179 +------------------------------ +---------------------------------------------------+180 | :c macro:`PyBUF_STRIDES` | This implies :cmacro:`PyBUF_ND`. The returned|181 | | buffer must provide strides information (i.e. the |182 | | strides cannot be NULL). This would be used when |183 | | the consumer can handle strided, discontiguous |184 | | arrays. Handling strides automatically assumes |185 | | you can handle shape. The exporter can raise an |186 | | error if a strided representation of the data is |187 | | not possible (i.e. without the suboffsets). |188 | | |189 +------------------------------ +---------------------------------------------------+190 | :c macro:`PyBUF_ND` | The returned buffer must provide shape |191 | | information. The memory will be assumed C-style |192 | | contiguous (last dimension varies the |193 | | fastest). The exporter may raise an error if it |194 | | cannot provide this kind of contiguous buffer. If |195 | | this is not given then shape will be *NULL*. |196 | | |197 | | |198 | | |199 +------------------------------ +---------------------------------------------------+200 |:c macro:`PyBUF_C_CONTIGUOUS` | These flags indicate that the contiguity returned |201 |:c macro:`PyBUF_F_CONTIGUOUS` | buffer must be respectively, C-contiguous (last |202 |:c macro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous |203 | | (first dimension varies the fastest) or either |204 | | one. All of these flags imply |205 | | :cmacro:`PyBUF_STRIDES` and guarantee that the|206 | | strides buffer info structure will be filled in |207 | | correctly. |208 | | |209 +------------------------------ +---------------------------------------------------+210 | :c macro:`PyBUF_INDIRECT` | This flag indicates the returned buffer must have |211 | | suboffsets information (which can be NULL if no |212 | | suboffsets are needed). This can be used when |213 | | the consumer can handle indirect array |214 | | referencing implied by these suboffsets. This |215 | | implies :cmacro:`PyBUF_STRIDES`.|216 | | |217 | | |218 | | |219 +------------------------------ +---------------------------------------------------+220 | :c macro:`PyBUF_FORMAT` | The returned buffer must have true format |221 | | information if this flag is provided. This would |222 | | be used when the consumer is going to be checking |223 | | for what 'kind' of data is actually stored. An |224 | | exporter should always be able to provide this |225 | | information if requested. If format is not |226 | | explicitly requested then the format must be |227 | | returned as *NULL* (which means ``'B'``, or |228 | | unsigned bytes) |229 +------------------------------ +---------------------------------------------------+230 | :c macro:`PyBUF_STRIDED` | This is equivalent to ``(PyBUF_STRIDES | |231 | | PyBUF_WRITABLE)``. |232 +------------------------------ +---------------------------------------------------+233 | :c macro:`PyBUF_STRIDED_RO` | This is equivalent to ``(PyBUF_STRIDES)``. |234 | | |235 +------------------------------ +---------------------------------------------------+236 | :c macro:`PyBUF_RECORDS` | This is equivalent to ``(PyBUF_STRIDES | |237 | | PyBUF_FORMAT | PyBUF_WRITABLE)``. |238 +------------------------------ +---------------------------------------------------+239 | :c macro:`PyBUF_RECORDS_RO` | This is equivalent to ``(PyBUF_STRIDES | |240 | | PyBUF_FORMAT)``. |241 +------------------------------ +---------------------------------------------------+242 | :c macro:`PyBUF_FULL` | This is equivalent to ``(PyBUF_INDIRECT | |243 | | PyBUF_FORMAT | PyBUF_WRITABLE)``. |244 +------------------------------ +---------------------------------------------------+245 | :c macro:`PyBUF_FULL_RO` | This is equivalent to ``(PyBUF_INDIRECT | |246 | | PyBUF_FORMAT)``. |247 +------------------------------ +---------------------------------------------------+248 | :c macro:`PyBUF_CONTIG` | This is equivalent to ``(PyBUF_ND | |249 | | PyBUF_WRITABLE)``. |250 +------------------------------ +---------------------------------------------------+251 | :c macro:`PyBUF_CONTIG_RO` | This is equivalent to ``(PyBUF_ND)``. |252 | | |253 +------------------------------ +---------------------------------------------------+254 255 256 .. c function:: void PyBuffer_Release(Py_buffer *view)166 +-------------------------------+---------------------------------------------------+ 167 | Flag | Description | 168 +===============================+===================================================+ 169 | :c:macro:`PyBUF_SIMPLE` | This is the default flag state. The returned | 170 | | buffer may or may not have writable memory. The | 171 | | format of the data will be assumed to be unsigned | 172 | | bytes. This is a "stand-alone" flag constant. It | 173 | | never needs to be '|'d to the others. The exporter| 174 | | will raise an error if it cannot provide such a | 175 | | contiguous buffer of bytes. | 176 | | | 177 +-------------------------------+---------------------------------------------------+ 178 | :c:macro:`PyBUF_WRITABLE` | The returned buffer must be writable. If it is | 179 | | not writable, then raise an error. | 180 +-------------------------------+---------------------------------------------------+ 181 | :c:macro:`PyBUF_STRIDES` | This implies :c:macro:`PyBUF_ND`. The returned | 182 | | buffer must provide strides information (i.e. the | 183 | | strides cannot be NULL). This would be used when | 184 | | the consumer can handle strided, discontiguous | 185 | | arrays. Handling strides automatically assumes | 186 | | you can handle shape. The exporter can raise an | 187 | | error if a strided representation of the data is | 188 | | not possible (i.e. without the suboffsets). | 189 | | | 190 +-------------------------------+---------------------------------------------------+ 191 | :c:macro:`PyBUF_ND` | The returned buffer must provide shape | 192 | | information. The memory will be assumed C-style | 193 | | contiguous (last dimension varies the | 194 | | fastest). The exporter may raise an error if it | 195 | | cannot provide this kind of contiguous buffer. If | 196 | | this is not given then shape will be *NULL*. | 197 | | | 198 | | | 199 | | | 200 +-------------------------------+---------------------------------------------------+ 201 |:c:macro:`PyBUF_C_CONTIGUOUS` | These flags indicate that the contiguity returned | 202 |:c:macro:`PyBUF_F_CONTIGUOUS` | buffer must be respectively, C-contiguous (last | 203 |:c:macro:`PyBUF_ANY_CONTIGUOUS`| dimension varies the fastest), Fortran contiguous | 204 | | (first dimension varies the fastest) or either | 205 | | one. All of these flags imply | 206 | | :c:macro:`PyBUF_STRIDES` and guarantee that the | 207 | | strides buffer info structure will be filled in | 208 | | correctly. | 209 | | | 210 +-------------------------------+---------------------------------------------------+ 211 | :c:macro:`PyBUF_INDIRECT` | This flag indicates the returned buffer must have | 212 | | suboffsets information (which can be NULL if no | 213 | | suboffsets are needed). This can be used when | 214 | | the consumer can handle indirect array | 215 | | referencing implied by these suboffsets. This | 216 | | implies :c:macro:`PyBUF_STRIDES`. | 217 | | | 218 | | | 219 | | | 220 +-------------------------------+---------------------------------------------------+ 221 | :c:macro:`PyBUF_FORMAT` | The returned buffer must have true format | 222 | | information if this flag is provided. This would | 223 | | be used when the consumer is going to be checking | 224 | | for what 'kind' of data is actually stored. An | 225 | | exporter should always be able to provide this | 226 | | information if requested. If format is not | 227 | | explicitly requested then the format must be | 228 | | returned as *NULL* (which means ``'B'``, or | 229 | | unsigned bytes) | 230 +-------------------------------+---------------------------------------------------+ 231 | :c:macro:`PyBUF_STRIDED` | This is equivalent to ``(PyBUF_STRIDES | | 232 | | PyBUF_WRITABLE)``. | 233 +-------------------------------+---------------------------------------------------+ 234 | :c:macro:`PyBUF_STRIDED_RO` | This is equivalent to ``(PyBUF_STRIDES)``. | 235 | | | 236 +-------------------------------+---------------------------------------------------+ 237 | :c:macro:`PyBUF_RECORDS` | This is equivalent to ``(PyBUF_STRIDES | | 238 | | PyBUF_FORMAT | PyBUF_WRITABLE)``. | 239 +-------------------------------+---------------------------------------------------+ 240 | :c:macro:`PyBUF_RECORDS_RO` | This is equivalent to ``(PyBUF_STRIDES | | 241 | | PyBUF_FORMAT)``. | 242 +-------------------------------+---------------------------------------------------+ 243 | :c:macro:`PyBUF_FULL` | This is equivalent to ``(PyBUF_INDIRECT | | 244 | | PyBUF_FORMAT | PyBUF_WRITABLE)``. | 245 +-------------------------------+---------------------------------------------------+ 246 | :c:macro:`PyBUF_FULL_RO` | This is equivalent to ``(PyBUF_INDIRECT | | 247 | | PyBUF_FORMAT)``. | 248 +-------------------------------+---------------------------------------------------+ 249 | :c:macro:`PyBUF_CONTIG` | This is equivalent to ``(PyBUF_ND | | 250 | | PyBUF_WRITABLE)``. | 251 +-------------------------------+---------------------------------------------------+ 252 | :c:macro:`PyBUF_CONTIG_RO` | This is equivalent to ``(PyBUF_ND)``. | 253 | | | 254 +-------------------------------+---------------------------------------------------+ 255 256 257 .. c:function:: void PyBuffer_Release(Py_buffer *view) 257 258 258 259 Release the buffer *view*. This should be called when the buffer … … 260 261 261 262 262 .. cfunction:: Py_ssize_t PyBuffer_SizeFromFormat(const char *) 263 264 Return the implied :cdata:`~Py_buffer.itemsize` from the struct-stype 265 :cdata:`~Py_buffer.format`. 266 267 268 .. cfunction:: int PyObject_CopyToObject(PyObject *obj, void *buf, Py_ssize_t len, char fortran) 269 270 Copy *len* bytes of data pointed to by the contiguous chunk of memory 271 pointed to by *buf* into the buffer exported by obj. The buffer must of 272 course be writable. Return 0 on success and return -1 and raise an error 273 on failure. If the object does not have a writable buffer, then an error 274 is raised. If *fortran* is ``'F'``, then if the object is 275 multi-dimensional, then the data will be copied into the array in 276 Fortran-style (first dimension varies the fastest). If *fortran* is 277 ``'C'``, then the data will be copied into the array in C-style (last 278 dimension varies the fastest). If *fortran* is ``'A'``, then it does not 279 matter and the copy will be made in whatever way is more efficient. 280 281 282 .. cfunction:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran) 263 .. c:function:: Py_ssize_t PyBuffer_SizeFromFormat(const char *) 264 265 Return the implied :c:data:`~Py_buffer.itemsize` from the struct-stype 266 :c:data:`~Py_buffer.format`. 267 268 269 .. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran) 283 270 284 271 Return 1 if the memory defined by the *view* is C-style (*fortran* is … … 287 274 288 275 289 .. c function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)276 .. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran) 290 277 291 278 Fill the *strides* array with byte-strides of a contiguous (C-style if 292 *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'`` array of the279 *fortran* is ``'C'`` or Fortran-style if *fortran* is ``'F'``) array of the 293 280 given shape with the given number of bytes per element. 294 281 295 282 296 .. c function:: int PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len, int readonly, int infoflags)283 .. c:function:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags) 297 284 298 285 Fill in a buffer-info structure, *view*, correctly for an exporter that can … … 301 288 302 289 290 MemoryView objects 291 ================== 292 293 .. versionadded:: 2.7 294 295 A :class:`memoryview` object exposes the new C level buffer interface as a 296 Python object which can then be passed around like any other object. 297 298 .. c:function:: PyObject *PyMemoryView_FromObject(PyObject *obj) 299 300 Create a memoryview object from an object that defines the new buffer 301 interface. 302 303 304 .. c:function:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view) 305 306 Create a memoryview object wrapping the given buffer-info structure *view*. 307 The memoryview object then owns the buffer, which means you shouldn't 308 try to release it yourself: it will be released on deallocation of the 309 memoryview object. 310 311 312 .. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order) 313 314 Create a memoryview object to a contiguous chunk of memory (in either 315 'C' or 'F'ortran *order*) from an object that defines the buffer 316 interface. If memory is contiguous, the memoryview object points to the 317 original memory. Otherwise copy is made and the memoryview points to a 318 new bytes object. 319 320 321 .. c:function:: int PyMemoryView_Check(PyObject *obj) 322 323 Return true if the object *obj* is a memoryview object. It is not 324 currently allowed to create subclasses of :class:`memoryview`. 325 326 327 .. c:function:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj) 328 329 Return a pointer to the buffer-info structure wrapped by the given 330 object. The object **must** be a memoryview instance; this macro doesn't 331 check its type, you must do it yourself or you will risk crashes. 332 333 303 334 Old-style buffer objects 304 335 ======================== … … 306 337 .. index:: single: PyBufferProcs 307 338 308 More information on the buffer interface is provided in the section309 :ref:`buffer-structs`, under the description for :c type:`PyBufferProcs`.339 More information on the old buffer interface is provided in the section 340 :ref:`buffer-structs`, under the description for :c:type:`PyBufferProcs`. 310 341 311 342 A "buffer object" is defined in the :file:`bufferobject.h` header (included by … … 326 357 327 358 328 .. c type:: PyBufferObject329 330 This subtype of :c type:`PyObject` represents a buffer object.331 332 333 .. c var:: PyTypeObject PyBuffer_Type359 .. c:type:: PyBufferObject 360 361 This subtype of :c:type:`PyObject` represents a buffer object. 362 363 364 .. c:var:: PyTypeObject PyBuffer_Type 334 365 335 366 .. index:: single: BufferType (in module types) 336 367 337 The instance of :c type:`PyTypeObject` which represents the Python buffer type;368 The instance of :c:type:`PyTypeObject` which represents the Python buffer type; 338 369 it is the same object as ``buffer`` and ``types.BufferType`` in the Python 339 370 layer. . 340 371 341 372 342 .. c var:: int Py_END_OF_BUFFER373 .. c:var:: int Py_END_OF_BUFFER 343 374 344 375 This constant may be passed as the *size* parameter to 345 :c func:`PyBuffer_FromObject` or :cfunc:`PyBuffer_FromReadWriteObject`. It346 indicates that the new :c type:`PyBufferObject` should refer to *base*376 :c:func:`PyBuffer_FromObject` or :c:func:`PyBuffer_FromReadWriteObject`. It 377 indicates that the new :c:type:`PyBufferObject` should refer to *base* 347 378 object from the specified *offset* to the end of its exported buffer. 348 379 Using this enables the caller to avoid querying the *base* object for its … … 350 381 351 382 352 .. c function:: int PyBuffer_Check(PyObject *p)353 354 Return true if the argument has type :c data:`PyBuffer_Type`.355 356 357 .. c function:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)383 .. c:function:: int PyBuffer_Check(PyObject *p) 384 385 Return true if the argument has type :c:data:`PyBuffer_Type`. 386 387 388 .. c:function:: PyObject* PyBuffer_FromObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) 358 389 359 390 Return a new read-only buffer object. This raises :exc:`TypeError` if … … 367 398 368 399 .. versionchanged:: 2.5 369 This function used an :c type:`int` type for *offset* and *size*. This400 This function used an :c:type:`int` type for *offset* and *size*. This 370 401 might require changes in your code for properly supporting 64-bit 371 402 systems. 372 403 373 404 374 .. c function:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size)405 .. c:function:: PyObject* PyBuffer_FromReadWriteObject(PyObject *base, Py_ssize_t offset, Py_ssize_t size) 375 406 376 407 Return a new writable buffer object. Parameters and exceptions are similar 377 to those for :c func:`PyBuffer_FromObject`. If the *base* object does not408 to those for :c:func:`PyBuffer_FromObject`. If the *base* object does not 378 409 export the writeable buffer protocol, then :exc:`TypeError` is raised. 379 410 380 411 .. versionchanged:: 2.5 381 This function used an :c type:`int` type for *offset* and *size*. This412 This function used an :c:type:`int` type for *offset* and *size*. This 382 413 might require changes in your code for properly supporting 64-bit 383 414 systems. 384 415 385 416 386 .. c function:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size)417 .. c:function:: PyObject* PyBuffer_FromMemory(void *ptr, Py_ssize_t size) 387 418 388 419 Return a new read-only buffer object that reads from a specified location … … 394 425 395 426 .. versionchanged:: 2.5 396 This function used an :c type:`int` type for *size*. This might require427 This function used an :c:type:`int` type for *size*. This might require 397 428 changes in your code for properly supporting 64-bit systems. 398 429 399 430 400 .. c function:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size)401 402 Similar to :c func:`PyBuffer_FromMemory`, but the returned buffer is431 .. c:function:: PyObject* PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size) 432 433 Similar to :c:func:`PyBuffer_FromMemory`, but the returned buffer is 403 434 writable. 404 435 405 436 .. versionchanged:: 2.5 406 This function used an :c type:`int` type for *size*. This might require437 This function used an :c:type:`int` type for *size*. This might require 407 438 changes in your code for properly supporting 64-bit systems. 408 439 409 440 410 .. c function:: PyObject* PyBuffer_New(Py_ssize_t size)441 .. c:function:: PyObject* PyBuffer_New(Py_ssize_t size) 411 442 412 443 Return a new writable buffer object that maintains its own memory buffer of 413 444 *size* bytes. :exc:`ValueError` is returned if *size* is not zero or 414 445 positive. Note that the memory buffer (as returned by 415 :c func:`PyObject_AsWriteBuffer`) is not specifically aligned.446 :c:func:`PyObject_AsWriteBuffer`) is not specifically aligned. 416 447 417 448 .. versionchanged:: 2.5 418 This function used an :c type:`int` type for *size*. This might require449 This function used an :c:type:`int` type for *size*. This might require 419 450 changes in your code for properly supporting 64-bit systems.
Note:
See TracChangeset
for help on using the changeset viewer.