Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

sliceobject.h 2.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  1. #ifndef Py_SLICEOBJECT_H
  2. #define Py_SLICEOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* The unique ellipsis object "..." */
  7. PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
  8. #define Py_Ellipsis (&_Py_EllipsisObject)
  9. /* Slice object interface */
  10. /*
  11. A slice object containing start, stop, and step data members (the
  12. names are from range). After much talk with Guido, it was decided to
  13. let these be any arbitrary python type. Py_None stands for omitted values.
  14. */
  15. #ifndef Py_LIMITED_API
  16. typedef struct {
  17. PyObject_HEAD
  18. PyObject *start, *stop, *step; /* not NULL */
  19. } PySliceObject;
  20. #endif
  21. PyAPI_DATA(PyTypeObject) PySlice_Type;
  22. PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
  23. #define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
  24. PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
  25. PyObject* step);
  26. #ifndef Py_LIMITED_API
  27. PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
  28. PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
  29. PyObject **start_ptr, PyObject **stop_ptr,
  30. PyObject **step_ptr);
  31. #endif
  32. PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
  33. Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
  34. PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
  35. Py_ssize_t *start, Py_ssize_t *stop,
  36. Py_ssize_t *step, Py_ssize_t *slicelength) Py_DEPRECATED(3.7);
  37. #if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100
  38. #define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \
  39. PySlice_Unpack((slice), (start), (stop), (step)) < 0 ? \
  40. ((*(slicelen) = 0), -1) : \
  41. ((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \
  42. 0))
  43. PyAPI_FUNC(int) PySlice_Unpack(PyObject *slice,
  44. Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
  45. PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,
  46. Py_ssize_t *start, Py_ssize_t *stop,
  47. Py_ssize_t step);
  48. #endif
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* !Py_SLICEOBJECT_H */
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...