Changeset 391 for python/trunk/Doc/c-api/long.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/long.rst
r2 r391 9 9 10 10 11 .. c type:: PyLongObject12 13 This subtype of :c type:`PyObject` represents a Python long integer object.14 15 16 .. c var:: PyTypeObject PyLong_Type11 .. c:type:: PyLongObject 12 13 This subtype of :c:type:`PyObject` represents a Python long integer object. 14 15 16 .. c:var:: PyTypeObject PyLong_Type 17 17 18 18 .. index:: single: LongType (in modules types) 19 19 20 This instance of :c type:`PyTypeObject` represents the Python long integer type.20 This instance of :c:type:`PyTypeObject` represents the Python long integer type. 21 21 This is the same object as ``long`` and ``types.LongType``. 22 22 23 23 24 .. c function:: int PyLong_Check(PyObject *p)25 26 Return true if its argument is a :c type:`PyLongObject` or a subtype of27 :c type:`PyLongObject`.24 .. c:function:: int PyLong_Check(PyObject *p) 25 26 Return true if its argument is a :c:type:`PyLongObject` or a subtype of 27 :c:type:`PyLongObject`. 28 28 29 29 .. versionchanged:: 2.2 … … 31 31 32 32 33 .. c function:: int PyLong_CheckExact(PyObject *p)34 35 Return true if its argument is a :c type:`PyLongObject`, but not a subtype of36 :c type:`PyLongObject`.33 .. c:function:: int PyLong_CheckExact(PyObject *p) 34 35 Return true if its argument is a :c:type:`PyLongObject`, but not a subtype of 36 :c:type:`PyLongObject`. 37 37 38 38 .. versionadded:: 2.2 39 39 40 40 41 .. c function:: PyObject* PyLong_FromLong(long v)42 43 Return a new :c type:`PyLongObject` object from *v*, or *NULL* on failure.44 45 46 .. c function:: PyObject* PyLong_FromUnsignedLong(unsigned long v)47 48 Return a new :c type:`PyLongObject` object from a C :ctype:`unsigned long`, or49 *NULL* on failure. 50 51 52 .. c function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v)53 54 Return a new :c type:`PyLongObject` object from a C :ctype:`Py_ssize_t`, or55 *NULL* on failure. 56 57 .. versionadded:: 2.6 58 59 60 .. c function:: PyObject* PyLong_FromSize_t(size_t v)61 62 Return a new :c type:`PyLongObject` object from a C :ctype:`size_t`, or63 *NULL* on failure. 64 65 .. versionadded:: 2.6 66 67 68 .. c function:: PyObject* PyLong_FromLongLong(PY_LONG_LONGv)69 70 Return a new :c type:`PyLongObject` object from a C :ctype:`long long`, or *NULL*41 .. c:function:: PyObject* PyLong_FromLong(long v) 42 43 Return a new :c:type:`PyLongObject` object from *v*, or *NULL* on failure. 44 45 46 .. c:function:: PyObject* PyLong_FromUnsignedLong(unsigned long v) 47 48 Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long`, or 49 *NULL* on failure. 50 51 52 .. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) 53 54 Return a new :c:type:`PyLongObject` object from a C :c:type:`Py_ssize_t`, or 55 *NULL* on failure. 56 57 .. versionadded:: 2.6 58 59 60 .. c:function:: PyObject* PyLong_FromSize_t(size_t v) 61 62 Return a new :c:type:`PyLongObject` object from a C :c:type:`size_t`, or 63 *NULL* on failure. 64 65 .. versionadded:: 2.6 66 67 68 .. c:function:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) 69 70 Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL* 71 71 on failure. 72 72 73 74 .. cfunction:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v) 75 76 Return a new :ctype:`PyLongObject` object from a C :ctype:`unsigned long long`, 73 .. versionadded:: 2.6 74 75 76 .. c:function:: PyObject* PyLong_FromSize_t(size_t v) 77 78 Return a new :c:type:`PyLongObject` object with a value of *v*, or *NULL* 79 on failure. 80 81 .. versionadded:: 2.6 82 83 84 .. c:function:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v) 85 86 Return a new :c:type:`PyLongObject` object from a C :c:type:`long long`, or *NULL* 87 on failure. 88 89 90 .. c:function:: PyObject* PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG v) 91 92 Return a new :c:type:`PyLongObject` object from a C :c:type:`unsigned long long`, 77 93 or *NULL* on failure. 78 94 79 95 80 .. c function:: PyObject* PyLong_FromDouble(double v)81 82 Return a new :c type:`PyLongObject` object from the integer part of *v*, or83 *NULL* on failure. 84 85 86 .. c function:: PyObject* PyLong_FromString(char *str, char **pend, int base)87 88 Return a new :c type:`PyLongObject` based on the string value in *str*, which is96 .. c:function:: PyObject* PyLong_FromDouble(double v) 97 98 Return a new :c:type:`PyLongObject` object from the integer part of *v*, or 99 *NULL* on failure. 100 101 102 .. c:function:: PyObject* PyLong_FromString(char *str, char **pend, int base) 103 104 Return a new :c:type:`PyLongObject` based on the string value in *str*, which is 89 105 interpreted according to the radix in *base*. If *pend* is non-*NULL*, 90 ``*pend``will point to the first character in *str* which follows the106 *\*pend* will point to the first character in *str* which follows the 91 107 representation of the number. If *base* is ``0``, the radix will be determined 92 108 based on the leading characters of *str*: if *str* starts with ``'0x'`` or … … 97 113 98 114 99 .. c function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base)115 .. c:function:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) 100 116 101 117 Convert a sequence of Unicode digits to a Python long integer value. The first … … 108 124 109 125 .. versionchanged:: 2.5 110 This function used an :c type:`int` for *length*. This might require126 This function used an :c:type:`int` for *length*. This might require 111 127 changes in your code for properly supporting 64-bit systems. 112 128 113 129 114 .. c function:: PyObject* PyLong_FromVoidPtr(void *p)130 .. c:function:: PyObject* PyLong_FromVoidPtr(void *p) 115 131 116 132 Create a Python integer or long integer from the pointer *p*. The pointer value 117 can be retrieved from the resulting value using :c func:`PyLong_AsVoidPtr`.133 can be retrieved from the resulting value using :c:func:`PyLong_AsVoidPtr`. 118 134 119 135 .. versionadded:: 1.5.2 … … 123 139 124 140 125 .. c function:: long PyLong_AsLong(PyObject *pylong)141 .. c:function:: long PyLong_AsLong(PyObject *pylong) 126 142 127 143 .. index:: … … 129 145 single: OverflowError (built-in exception) 130 146 131 Return a C :c type:`long` representation of the contents of *pylong*. If147 Return a C :c:type:`long` representation of the contents of *pylong*. If 132 148 *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised 133 149 and ``-1`` will be returned. 134 150 135 151 136 .. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) 152 .. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow) 153 154 Return a C :c:type:`long` representation of the contents of 155 *pylong*. If *pylong* is greater than :const:`LONG_MAX` or less 156 than :const:`LONG_MIN`, set *\*overflow* to ``1`` or ``-1``, 157 respectively, and return ``-1``; otherwise, set *\*overflow* to 158 ``0``. If any other exception occurs (for example a TypeError or 159 MemoryError), then ``-1`` will be returned and *\*overflow* will 160 be ``0``. 161 162 .. versionadded:: 2.7 163 164 165 .. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow) 166 167 Return a C :c:type:`long long` representation of the contents of 168 *pylong*. If *pylong* is greater than :const:`PY_LLONG_MAX` or less 169 than :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, 170 respectively, and return ``-1``; otherwise, set *\*overflow* to 171 ``0``. If any other exception occurs (for example a TypeError or 172 MemoryError), then ``-1`` will be returned and *\*overflow* will 173 be ``0``. 174 175 .. versionadded:: 2.7 176 177 178 .. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) 137 179 138 180 .. index:: … … 140 182 single: OverflowError (built-in exception) 141 183 142 Return a C :c type:`Py_ssize_t` representation of the contents of *pylong*. If184 Return a C :c:type:`Py_ssize_t` representation of the contents of *pylong*. If 143 185 *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is raised 144 186 and ``-1`` will be returned. … … 147 189 148 190 149 .. c function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong)191 .. c:function:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong) 150 192 151 193 .. index:: … … 153 195 single: OverflowError (built-in exception) 154 196 155 Return a C :c type:`unsigned long` representation of the contents of *pylong*.197 Return a C :c:type:`unsigned long` representation of the contents of *pylong*. 156 198 If *pylong* is greater than :const:`ULONG_MAX`, an :exc:`OverflowError` is 157 199 raised. 158 200 159 201 160 .. cfunction:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong) 161 162 Return a C :ctype:`long long` from a Python long integer. If *pylong* cannot be 163 represented as a :ctype:`long long`, an :exc:`OverflowError` will be raised. 202 .. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) 203 204 .. index:: 205 single: PY_SSIZE_T_MAX 206 207 Return a :c:type:`Py_ssize_t` representation of the contents of *pylong*. If 208 *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is 209 raised. 210 211 .. versionadded:: 2.6 212 213 214 .. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong) 215 216 .. index:: 217 single: OverflowError (built-in exception) 218 219 Return a C :c:type:`long long` from a Python long integer. If 220 *pylong* cannot be represented as a :c:type:`long long`, an 221 :exc:`OverflowError` is raised and ``-1`` is returned. 164 222 165 223 .. versionadded:: 2.2 166 224 167 225 168 .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) 169 170 Return a C :ctype:`unsigned long long` from a Python long integer. If *pylong* 171 cannot be represented as an :ctype:`unsigned long long`, an :exc:`OverflowError` 172 will be raised if the value is positive, or a :exc:`TypeError` will be raised if 173 the value is negative. 226 .. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) 227 228 .. index:: 229 single: OverflowError (built-in exception) 230 231 Return a C :c:type:`unsigned long long` from a Python long integer. If 232 *pylong* cannot be represented as an :c:type:`unsigned long long`, an 233 :exc:`OverflowError` is raised and ``(unsigned long long)-1`` is 234 returned. 174 235 175 236 .. versionadded:: 2.2 176 237 177 178 .. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) 179 180 Return a C :ctype:`unsigned long` from a Python long integer, without checking 238 .. versionchanged:: 2.7 239 A negative *pylong* now raises :exc:`OverflowError`, not 240 :exc:`TypeError`. 241 242 243 .. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) 244 245 Return a C :c:type:`unsigned long` from a Python long integer, without checking 181 246 for overflow. 182 247 … … 184 249 185 250 186 .. c function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io)187 188 Return a C :c type:`unsigned long long` from a Python long integer, without251 .. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io) 252 253 Return a C :c:type:`unsigned long long` from a Python long integer, without 189 254 checking for overflow. 190 255 … … 192 257 193 258 194 .. c function:: double PyLong_AsDouble(PyObject *pylong)195 196 Return a C :c type:`double` representation of the contents of *pylong*. If197 *pylong* cannot be approximately represented as a :c type:`double`, an259 .. c:function:: double PyLong_AsDouble(PyObject *pylong) 260 261 Return a C :c:type:`double` representation of the contents of *pylong*. If 262 *pylong* cannot be approximately represented as a :c:type:`double`, an 198 263 :exc:`OverflowError` exception is raised and ``-1.0`` will be returned. 199 264 200 265 201 .. c function:: void* PyLong_AsVoidPtr(PyObject *pylong)202 203 Convert a Python integer or long integer *pylong* to a C :c type:`void` pointer.266 .. c:function:: void* PyLong_AsVoidPtr(PyObject *pylong) 267 268 Convert a Python integer or long integer *pylong* to a C :c:type:`void` pointer. 204 269 If *pylong* cannot be converted, an :exc:`OverflowError` will be raised. This 205 is only assured to produce a usable :c type:`void` pointer for values created206 with :c func:`PyLong_FromVoidPtr`.270 is only assured to produce a usable :c:type:`void` pointer for values created 271 with :c:func:`PyLong_FromVoidPtr`. 207 272 208 273 .. versionadded:: 1.5.2
Note:
See TracChangeset
for help on using the changeset viewer.