Mercurial > cpython-lru_cache-weakref
annotate Doc/c-api/objbuffer.rst @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 25c20a77f373 |
| children | b36cb4602e21 |
| rev | line source |
|---|---|
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 .. highlightlang:: c |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 .. _abstract-buffer: |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 |
|
52749
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
5 |
|
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
6 Old Buffer Protocol |
|
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
7 =================== |
|
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
8 |
|
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
9 This section describes the legacy buffer protocol, which has been introduced |
|
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
10 in Python 1.6. It is still supported but deprecated in the Python 2.x series. |
|
75efd757434b
Issue #2396: backport the memoryview object.
Antoine Pitrou <solipsis@pitrou.net>
parents:
45429
diff
changeset
|
11 Python 3.0 introduces a new buffer protocol which fixes weaknesses and |
|
53432
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
12 shortcomings of the protocol, and has been backported to Python 2.6. See |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
13 :ref:`bufferobjects` for more information. |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
15 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
16 .. cfunction:: int PyObject_AsCharBuffer(PyObject *obj, const char **buffer, Py_ssize_t *buffer_len) |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
17 |
|
45429
853af5bbb497
A lot more typo fixes by Ori Avtalion.
Georg Brandl <georg@python.org>
parents:
44796
diff
changeset
|
18 Returns a pointer to a read-only memory location usable as character-based |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
19 input. The *obj* argument must support the single-segment character buffer |
|
53432
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
20 interface. On success, returns ``0``, sets *buffer* to the memory location |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
21 and *buffer_len* to the buffer length. Returns ``-1`` and sets a |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
22 :exc:`TypeError` on error. |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
23 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
24 .. versionadded:: 1.6 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
25 |
|
53433
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
26 .. versionchanged:: 2.5 |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
27 This function used an :ctype:`int *` type for *buffer_len*. This might |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
28 require changes in your code for properly supporting 64-bit systems. |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
29 |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
30 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
31 .. cfunction:: int PyObject_AsReadBuffer(PyObject *obj, const void **buffer, Py_ssize_t *buffer_len) |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
32 |
|
53432
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
33 Returns a pointer to a read-only memory location containing arbitrary data. |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
34 The *obj* argument must support the single-segment readable buffer |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
35 interface. On success, returns ``0``, sets *buffer* to the memory location |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
36 and *buffer_len* to the buffer length. Returns ``-1`` and sets a |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
37 :exc:`TypeError` on error. |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
38 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
39 .. versionadded:: 1.6 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
40 |
|
53433
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
41 .. versionchanged:: 2.5 |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
42 This function used an :ctype:`int *` type for *buffer_len*. This might |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
43 require changes in your code for properly supporting 64-bit systems. |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
44 |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
45 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
46 .. cfunction:: int PyObject_CheckReadBuffer(PyObject *o) |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
47 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
48 Returns ``1`` if *o* supports the single-segment readable buffer interface. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
49 Otherwise returns ``0``. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
50 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
51 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
52 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
53 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
54 .. cfunction:: int PyObject_AsWriteBuffer(PyObject *obj, void **buffer, Py_ssize_t *buffer_len) |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
55 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
56 Returns a pointer to a writeable memory location. The *obj* argument must |
|
53432
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
57 support the single-segment, character buffer interface. On success, |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
58 returns ``0``, sets *buffer* to the memory location and *buffer_len* to the |
|
c7ea826fad77
Reformat prior to editing.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
52749
diff
changeset
|
59 buffer length. Returns ``-1`` and sets a :exc:`TypeError` on error. |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
60 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
61 .. versionadded:: 1.6 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
62 |
|
53433
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
63 .. versionchanged:: 2.5 |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
64 This function used an :ctype:`int *` type for *buffer_len*. This might |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
65 require changes in your code for properly supporting 64-bit systems. |
|
25c20a77f373
Issue #4129: int -> Py_ssize_t documentation.
Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
parents:
53432
diff
changeset
|
66 |
