Mercurial > cpython-lru_cache-weakref
annotate Doc/c-api/memoryview.rst @ 78069:a8aa77458e12 3.2
Add c_size_t and c_ssize_t to the ctypes summary table.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Thu, 12 Jul 2012 20:31:50 +0200 |
| parents | 0f2e10596332 |
| children | 3f9b3b6f7ff0 |
| rev | line source |
|---|---|
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
1 .. highlightlang:: c |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
2 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
3 .. _memoryview-objects: |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
4 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
5 .. index:: |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
6 object: memoryview |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
7 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
8 MemoryView objects |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
9 ------------------ |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
10 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
11 A :class:`memoryview` object exposes the C level :ref:`buffer interface |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
12 <bufferobjects>` as a Python object which can then be passed around like |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
13 any other object. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
14 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
15 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
64998
diff
changeset
|
16 .. c:function:: PyObject *PyMemoryView_FromObject(PyObject *obj) |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
17 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
18 Create a memoryview object from an object that provides the buffer interface. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
19 If *obj* supports writable buffer exports, the memoryview object will be |
|
73733
0f2e10596332
fix some typos in Doc/c-api/memoryview.rst
Eli Bendersky <eliben@gmail.com>
parents:
65137
diff
changeset
|
20 readable and writable, otherwise it will be read-only. |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
21 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
22 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
64998
diff
changeset
|
23 .. c:function:: PyObject *PyMemoryView_FromBuffer(Py_buffer *view) |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
24 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
25 Create a memoryview object wrapping the given buffer structure *view*. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
26 The memoryview object then owns the buffer represented by *view*, which |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
64998
diff
changeset
|
27 means you shouldn't try to call :c:func:`PyBuffer_Release` yourself: it |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
28 will be done on deallocation of the memoryview object. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
29 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
30 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
64998
diff
changeset
|
31 .. c:function:: PyObject *PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char order) |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
32 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
33 Create a memoryview object to a contiguous chunk of memory (in either |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
34 'C' or 'F'ortran *order*) from an object that defines the buffer |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
35 interface. If memory is contiguous, the memoryview object points to the |
|
73733
0f2e10596332
fix some typos in Doc/c-api/memoryview.rst
Eli Bendersky <eliben@gmail.com>
parents:
65137
diff
changeset
|
36 original memory. Otherwise, a copy is made and the memoryview points to a |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
37 new bytes object. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
38 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
39 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
64998
diff
changeset
|
40 .. c:function:: int PyMemoryView_Check(PyObject *obj) |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
41 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
42 Return true if the object *obj* is a memoryview object. It is not |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
43 currently allowed to create subclasses of :class:`memoryview`. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
44 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
45 |
|
65137
521eac31a893
Migrate to Sphinx 1.0 C language constructs.
Georg Brandl <georg@python.org>
parents:
64998
diff
changeset
|
46 .. c:function:: Py_buffer *PyMemoryView_GET_BUFFER(PyObject *obj) |
|
64998
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
47 |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
48 Return a pointer to the buffer structure wrapped by the given |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
49 memoryview object. The object **must** be a memoryview instance; |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
50 this macro doesn't check its type, you must do it yourself or you |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
51 will risk crashes. |
|
06f5e190855a
Give a dedicated page to memoryview objects, so that they can be part
Antoine Pitrou <solipsis@pitrou.net>
parents:
diff
changeset
|
52 |
