OLD | NEW |
(Empty) | |
| 1 cdef extern from "Python.h": |
| 2 ctypedef unsigned long long PY_LONG_LONG |
| 3 |
| 4 ############################################################################ |
| 5 # Integer Objects |
| 6 ############################################################################ |
| 7 # PyTypeObject PyInt_Type |
| 8 # This instance of PyTypeObject represents the Python plain |
| 9 # integer type. This is the same object as int and types.IntType. |
| 10 |
| 11 bint PyInt_Check(object o) |
| 12 # Return true if o is of type PyInt_Type or a subtype of |
| 13 # PyInt_Type. |
| 14 |
| 15 bint PyInt_CheckExact(object o) |
| 16 # Return true if o is of type PyInt_Type, but not a subtype of |
| 17 # PyInt_Type. |
| 18 |
| 19 object PyInt_FromString(char *str, char **pend, int base) |
| 20 # Return value: New reference. |
| 21 # Return a new PyIntObject or PyLongObject based on the string |
| 22 # value in str, which is interpreted according to the radix in |
| 23 # base. If pend is non-NULL, *pend will point to the first |
| 24 # character in str which follows the representation of the |
| 25 # number. If base is 0, the radix will be determined based on the |
| 26 # leading characters of str: if str starts with '0x' or '0X', |
| 27 # radix 16 will be used; if str starts with '0', radix 8 will be |
| 28 # used; otherwise radix 10 will be used. If base is not 0, it must |
| 29 # be between 2 and 36, inclusive. Leading spaces are ignored. If |
| 30 # there are no digits, ValueError will be raised. If the string |
| 31 # represents a number too large to be contained within the |
| 32 # machine's long int type and overflow warnings are being |
| 33 # suppressed, a PyLongObject will be returned. If overflow |
| 34 # warnings are not being suppressed, NULL will be returned in this |
| 35 # case. |
| 36 |
| 37 object PyInt_FromLong(long ival) |
| 38 # Return value: New reference. |
| 39 # Create a new integer object with a value of ival. |
| 40 # The current implementation keeps an array of integer objects for |
| 41 # all integers between -5 and 256, when you create an int in that |
| 42 # range you actually just get back a reference to the existing |
| 43 # object. So it should be possible to change the value of 1. I |
| 44 # suspect the behaviour of Python in this case is undefined. :-) |
| 45 |
| 46 object PyInt_FromSsize_t(Py_ssize_t ival) |
| 47 # Return value: New reference. |
| 48 # Create a new integer object with a value of ival. If the value |
| 49 # exceeds LONG_MAX, a long integer object is returned. |
| 50 |
| 51 long PyInt_AsLong(object io) except? -1 |
| 52 # Will first attempt to cast the object to a PyIntObject, if it is |
| 53 # not already one, and then return its value. If there is an |
| 54 # error, -1 is returned, and the caller should check |
| 55 # PyErr_Occurred() to find out whether there was an error, or |
| 56 # whether the value just happened to be -1. |
| 57 |
| 58 long PyInt_AS_LONG(object io) |
| 59 # Return the value of the object io. No error checking is performed. |
| 60 |
| 61 unsigned long PyInt_AsUnsignedLongMask(object io) except? -1 |
| 62 # Will first attempt to cast the object to a PyIntObject or |
| 63 # PyLongObject, if it is not already one, and then return its |
| 64 # value as unsigned long. This function does not check for |
| 65 # overflow. |
| 66 |
| 67 PY_LONG_LONG PyInt_AsUnsignedLongLongMask(object io) except? -1 |
| 68 # Will first attempt to cast the object to a PyIntObject or |
| 69 # PyLongObject, if it is not already one, and then return its |
| 70 # value as unsigned long long, without checking for overflow. |
| 71 |
| 72 Py_ssize_t PyInt_AsSsize_t(object io) except? -1 |
| 73 # Will first attempt to cast the object to a PyIntObject or |
| 74 # PyLongObject, if it is not already one, and then return its |
| 75 # value as Py_ssize_t. |
| 76 |
| 77 long PyInt_GetMax() |
| 78 # Return the system's idea of the largest integer it can handle |
| 79 # (LONG_MAX, as defined in the system header files). |
OLD | NEW |