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

memoryobject.h 2.7 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
64
65
66
67
68
69
70
71
72
  1. /* Memory view object. In Python this is available as "memoryview". */
  2. #ifndef Py_MEMORYOBJECT_H
  3. #define Py_MEMORYOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #ifndef Py_LIMITED_API
  8. PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type;
  9. #endif
  10. PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
  11. #define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type)
  12. #ifndef Py_LIMITED_API
  13. /* Get a pointer to the memoryview's private copy of the exporter's buffer. */
  14. #define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
  15. /* Get a pointer to the exporting object (this may be NULL!). */
  16. #define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
  17. #endif
  18. PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base);
  19. #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
  20. PyAPI_FUNC(PyObject *) PyMemoryView_FromMemory(char *mem, Py_ssize_t size,
  21. int flags);
  22. #endif
  23. #ifndef Py_LIMITED_API
  24. PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info);
  25. #endif
  26. PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base,
  27. int buffertype,
  28. char order);
  29. /* The structs are declared here so that macros can work, but they shouldn't
  30. be considered public. Don't access their fields directly, use the macros
  31. and functions instead! */
  32. #ifndef Py_LIMITED_API
  33. #define _Py_MANAGED_BUFFER_RELEASED 0x001 /* access to exporter blocked */
  34. #define _Py_MANAGED_BUFFER_FREE_FORMAT 0x002 /* free format */
  35. typedef struct {
  36. PyObject_HEAD
  37. int flags; /* state flags */
  38. Py_ssize_t exports; /* number of direct memoryview exports */
  39. Py_buffer master; /* snapshot buffer obtained from the original exporter */
  40. } _PyManagedBufferObject;
  41. /* memoryview state flags */
  42. #define _Py_MEMORYVIEW_RELEASED 0x001 /* access to master buffer blocked */
  43. #define _Py_MEMORYVIEW_C 0x002 /* C-contiguous layout */
  44. #define _Py_MEMORYVIEW_FORTRAN 0x004 /* Fortran contiguous layout */
  45. #define _Py_MEMORYVIEW_SCALAR 0x008 /* scalar: ndim = 0 */
  46. #define _Py_MEMORYVIEW_PIL 0x010 /* PIL-style layout */
  47. typedef struct {
  48. PyObject_VAR_HEAD
  49. _PyManagedBufferObject *mbuf; /* managed buffer */
  50. Py_hash_t hash; /* hash value for read-only views */
  51. int flags; /* state flags */
  52. Py_ssize_t exports; /* number of buffer re-exports */
  53. Py_buffer view; /* private copy of the exporter's view */
  54. PyObject *weakreflist;
  55. Py_ssize_t ob_array[1]; /* shape, strides, suboffsets */
  56. } PyMemoryViewObject;
  57. #endif
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif /* !Py_MEMORYOBJECT_H */
Tip!

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

Comments

Loading...