int.pxd 4.0 KB

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