cython

Форк
0
72 строки · 3.1 Кб
1
from .object cimport PyObject
2

3
cdef extern from "Python.h":
4

5
    ############################################################################
6
    # Tuples
7
    ############################################################################
8

9
    bint PyTuple_Check(object  p)
10
    # Return true if p is a tuple object or an instance of a subtype
11
    # of the tuple type.
12

13
    bint PyTuple_CheckExact(object  p)
14
    # Return true if p is a tuple object, but not an instance of a subtype of the tuple type.
15

16
    tuple PyTuple_New(Py_ssize_t len)
17
    # Return value: New reference.
18
    # Return a new tuple object of size len, or NULL on failure.
19

20
    tuple PyTuple_Pack(Py_ssize_t n, ...)
21
    # Return value: New reference.
22
    # Return a new tuple object of size n, or NULL on failure. The
23
    # tuple values are initialized to the subsequent n C arguments
24
    # pointing to Python objects. "PyTuple_Pack(2, a, b)" is
25
    # equivalent to "Py_BuildValue("(OO)", a, b)".
26

27
    Py_ssize_t PyTuple_Size(object  p) except -1
28
    # Take a pointer to a tuple object, and return the size of that tuple.
29

30
    Py_ssize_t PyTuple_GET_SIZE(object  p)
31
    # Return the size of the tuple p, which must be non-NULL and point
32
    # to a tuple; no error checking is performed.
33

34
    PyObject* PyTuple_GetItem(object  p, Py_ssize_t pos) except NULL
35
    # Return value: Borrowed reference.
36
    # Return the object at position pos in the tuple pointed to by
37
    # p. If pos is out of bounds, return NULL and sets an IndexError
38
    # exception.
39

40
    PyObject* PyTuple_GET_ITEM(object  p, Py_ssize_t pos)
41
    # Return value: Borrowed reference.
42
    # Like PyTuple_GetItem(), but does no checking of its arguments.
43

44
    tuple PyTuple_GetSlice(object  p, Py_ssize_t low, Py_ssize_t high)
45
    # Return value: New reference.
46
    # Take a slice of the tuple pointed to by p from low to high and return it as a new tuple.
47

48
    int PyTuple_SetItem(object  p, Py_ssize_t pos, object  o) except -1
49
    # Insert a reference to object o at position pos of the tuple
50
    # pointed to by p. Return 0 on success.
51
    #
52
    # WARNING: This function _steals_ a reference to o.
53

54
    void PyTuple_SET_ITEM(object  p, Py_ssize_t pos, object  o)
55
    # Like PyTuple_SetItem(), but does no error checking, and should
56
    # only be used to fill in brand new tuples.
57
    #
58
    # WARNING: This function _steals_ a reference to o.
59

60
    int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize) except -1
61
    # Can be used to resize a tuple. newsize will be the new length of
62
    # the tuple. Because tuples are supposed to be immutable, this
63
    # should only be used if there is only one reference to the
64
    # object. Do not use this if the tuple may already be known to
65
    # some other part of the code. The tuple will always grow or
66
    # shrink at the end. Think of this as destroying the old tuple and
67
    # creating a new one, only more efficiently. Returns 0 on
68
    # success. Client code should never assume that the resulting
69
    # value of *p will be the same as before calling this function. If
70
    # the object referenced by *p is replaced, the original *p is
71
    # destroyed. On failure, returns -1 and sets *p to NULL, and
72
    # raises MemoryError or SystemError.
73

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.