~pythonregexp2.7/python/issue2636-12

« back to all changes in this revision

Viewing changes to Doc/c-api/bytearray.rst

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-06-09 14:52:42 UTC
  • mfrom: (39033.1.3 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080609145242-9m268zc6u87rp1vp
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. highlightlang:: c
 
2
 
 
3
.. _bytearrayobjects:
 
4
 
 
5
Byte Array Objects
 
6
------------------
 
7
 
 
8
.. index:: object: bytearray
 
9
 
 
10
.. versionadded:: 2.6
 
11
 
 
12
 
 
13
.. ctype:: PyByteArrayObject
 
14
 
 
15
   This subtype of :ctype:`PyObject` represents a Python bytearray object.
 
16
 
 
17
 
 
18
.. cvar:: PyTypeObject PyByteArray_Type
 
19
 
 
20
   This instance of :ctype:`PyTypeObject` represents the Python bytearray type;
 
21
   it is the same object as ``bytearray`` in the Python layer.
 
22
 
 
23
 
 
24
.. cfunction:: int PyByteArray_Check(PyObject *o)
 
25
 
 
26
   Return true if the object *o* is a bytearray object or an instance of a
 
27
   subtype of the bytearray type.
 
28
 
 
29
 
 
30
.. cfunction:: int PyByteArray_CheckExact(PyObject *o)
 
31
 
 
32
   Return true if the object *o* is a bytearray object, but not an instance of a
 
33
   subtype of the bytearray type.
 
34
 
 
35
 
 
36
.. cfunction:: PyObject* PyByteArray_FromObject(PyObject *o)
 
37
 
 
38
   Return a new bytearray object from any object, *o*, that implements the
 
39
   buffer protocol.
 
40
 
 
41
   .. XXX expand about the buffer protocol, at least somewhere
 
42
 
 
43
 
 
44
.. cfunction:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
 
45
 
 
46
   Create a new bytearray object from *string* and its length, *len*.  On
 
47
   failure, *NULL* is returned.
 
48
 
 
49
 
 
50
.. cfunction:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
 
51
 
 
52
   Return the size of *bytearray* after checking for a *NULL* pointer.
 
53
 
 
54
 
 
55
.. cfunction:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
 
56
 
 
57
   Macro version of :cfunc:`PyByteArray_Size` that doesn't do pointer checking.
 
58
 
 
59
 
 
60
.. cfunction:: char* PyByteArray_AsString(PyObject *bytearray)
 
61
 
 
62
   Return the contents of *bytearray* as a char array after checking for a
 
63
   *NULL* pointer.
 
64
 
 
65
 
 
66
.. cfunction:: char* PyByteArray_AS_STRING(PyObject *bytearray)
 
67
 
 
68
   Macro version of :cfunc:`PyByteArray_AsString` that doesn't check pointers.
 
69
 
 
70
 
 
71
.. cfunction:: PyObject* PyByteArray_Concat(PyObject *a, PyObject *b)
 
72
 
 
73
   Concat bytearrays *a* and *b* and return a new bytearray with the result.
 
74
 
 
75
 
 
76
.. cfunction:: PyObject* PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
 
77
 
 
78
   Resize the internal buffer of *bytearray* to *len*.