• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(_tracemalloc_is_tracing__doc__,
6 "is_tracing($module, /)\n"
7 "--\n"
8 "\n"
9 "Return True if the tracemalloc module is tracing Python memory allocations.");
10 
11 #define _TRACEMALLOC_IS_TRACING_METHODDEF    \
12     {"is_tracing", (PyCFunction)_tracemalloc_is_tracing, METH_NOARGS, _tracemalloc_is_tracing__doc__},
13 
14 static PyObject *
15 _tracemalloc_is_tracing_impl(PyObject *module);
16 
17 static PyObject *
_tracemalloc_is_tracing(PyObject * module,PyObject * Py_UNUSED (ignored))18 _tracemalloc_is_tracing(PyObject *module, PyObject *Py_UNUSED(ignored))
19 {
20     return _tracemalloc_is_tracing_impl(module);
21 }
22 
23 PyDoc_STRVAR(_tracemalloc_clear_traces__doc__,
24 "clear_traces($module, /)\n"
25 "--\n"
26 "\n"
27 "Clear traces of memory blocks allocated by Python.");
28 
29 #define _TRACEMALLOC_CLEAR_TRACES_METHODDEF    \
30     {"clear_traces", (PyCFunction)_tracemalloc_clear_traces, METH_NOARGS, _tracemalloc_clear_traces__doc__},
31 
32 static PyObject *
33 _tracemalloc_clear_traces_impl(PyObject *module);
34 
35 static PyObject *
_tracemalloc_clear_traces(PyObject * module,PyObject * Py_UNUSED (ignored))36 _tracemalloc_clear_traces(PyObject *module, PyObject *Py_UNUSED(ignored))
37 {
38     return _tracemalloc_clear_traces_impl(module);
39 }
40 
41 PyDoc_STRVAR(_tracemalloc__get_traces__doc__,
42 "_get_traces($module, /)\n"
43 "--\n"
44 "\n"
45 "Get traces of all memory blocks allocated by Python.\n"
46 "\n"
47 "Return a list of (size: int, traceback: tuple) tuples.\n"
48 "traceback is a tuple of (filename: str, lineno: int) tuples.\n"
49 "\n"
50 "Return an empty list if the tracemalloc module is disabled.");
51 
52 #define _TRACEMALLOC__GET_TRACES_METHODDEF    \
53     {"_get_traces", (PyCFunction)_tracemalloc__get_traces, METH_NOARGS, _tracemalloc__get_traces__doc__},
54 
55 static PyObject *
56 _tracemalloc__get_traces_impl(PyObject *module);
57 
58 static PyObject *
_tracemalloc__get_traces(PyObject * module,PyObject * Py_UNUSED (ignored))59 _tracemalloc__get_traces(PyObject *module, PyObject *Py_UNUSED(ignored))
60 {
61     return _tracemalloc__get_traces_impl(module);
62 }
63 
64 PyDoc_STRVAR(_tracemalloc__get_object_traceback__doc__,
65 "_get_object_traceback($module, obj, /)\n"
66 "--\n"
67 "\n"
68 "Get the traceback where the Python object obj was allocated.\n"
69 "\n"
70 "Return a tuple of (filename: str, lineno: int) tuples.\n"
71 "Return None if the tracemalloc module is disabled or did not\n"
72 "trace the allocation of the object.");
73 
74 #define _TRACEMALLOC__GET_OBJECT_TRACEBACK_METHODDEF    \
75     {"_get_object_traceback", (PyCFunction)_tracemalloc__get_object_traceback, METH_O, _tracemalloc__get_object_traceback__doc__},
76 
77 PyDoc_STRVAR(_tracemalloc_start__doc__,
78 "start($module, nframe=1, /)\n"
79 "--\n"
80 "\n"
81 "Start tracing Python memory allocations.\n"
82 "\n"
83 "Also set the maximum number of frames stored in the traceback of a\n"
84 "trace to nframe.");
85 
86 #define _TRACEMALLOC_START_METHODDEF    \
87     {"start", (PyCFunction)_tracemalloc_start, METH_FASTCALL, _tracemalloc_start__doc__},
88 
89 static PyObject *
90 _tracemalloc_start_impl(PyObject *module, int nframe);
91 
92 static PyObject *
_tracemalloc_start(PyObject * module,PyObject * const * args,Py_ssize_t nargs)93 _tracemalloc_start(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
94 {
95     PyObject *return_value = NULL;
96     int nframe = 1;
97 
98     if (!_PyArg_ParseStack(args, nargs, "|i:start",
99         &nframe)) {
100         goto exit;
101     }
102     return_value = _tracemalloc_start_impl(module, nframe);
103 
104 exit:
105     return return_value;
106 }
107 
108 PyDoc_STRVAR(_tracemalloc_stop__doc__,
109 "stop($module, /)\n"
110 "--\n"
111 "\n"
112 "Stop tracing Python memory allocations.\n"
113 "\n"
114 "Also clear traces of memory blocks allocated by Python.");
115 
116 #define _TRACEMALLOC_STOP_METHODDEF    \
117     {"stop", (PyCFunction)_tracemalloc_stop, METH_NOARGS, _tracemalloc_stop__doc__},
118 
119 static PyObject *
120 _tracemalloc_stop_impl(PyObject *module);
121 
122 static PyObject *
_tracemalloc_stop(PyObject * module,PyObject * Py_UNUSED (ignored))123 _tracemalloc_stop(PyObject *module, PyObject *Py_UNUSED(ignored))
124 {
125     return _tracemalloc_stop_impl(module);
126 }
127 
128 PyDoc_STRVAR(_tracemalloc_get_traceback_limit__doc__,
129 "get_traceback_limit($module, /)\n"
130 "--\n"
131 "\n"
132 "Get the maximum number of frames stored in the traceback of a trace.\n"
133 "\n"
134 "By default, a trace of an allocated memory block only stores\n"
135 "the most recent frame: the limit is 1.");
136 
137 #define _TRACEMALLOC_GET_TRACEBACK_LIMIT_METHODDEF    \
138     {"get_traceback_limit", (PyCFunction)_tracemalloc_get_traceback_limit, METH_NOARGS, _tracemalloc_get_traceback_limit__doc__},
139 
140 static PyObject *
141 _tracemalloc_get_traceback_limit_impl(PyObject *module);
142 
143 static PyObject *
_tracemalloc_get_traceback_limit(PyObject * module,PyObject * Py_UNUSED (ignored))144 _tracemalloc_get_traceback_limit(PyObject *module, PyObject *Py_UNUSED(ignored))
145 {
146     return _tracemalloc_get_traceback_limit_impl(module);
147 }
148 
149 PyDoc_STRVAR(_tracemalloc_get_tracemalloc_memory__doc__,
150 "get_tracemalloc_memory($module, /)\n"
151 "--\n"
152 "\n"
153 "Get the memory usage in bytes of the tracemalloc module.\n"
154 "\n"
155 "This memory is used internally to trace memory allocations.");
156 
157 #define _TRACEMALLOC_GET_TRACEMALLOC_MEMORY_METHODDEF    \
158     {"get_tracemalloc_memory", (PyCFunction)_tracemalloc_get_tracemalloc_memory, METH_NOARGS, _tracemalloc_get_tracemalloc_memory__doc__},
159 
160 static PyObject *
161 _tracemalloc_get_tracemalloc_memory_impl(PyObject *module);
162 
163 static PyObject *
_tracemalloc_get_tracemalloc_memory(PyObject * module,PyObject * Py_UNUSED (ignored))164 _tracemalloc_get_tracemalloc_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
165 {
166     return _tracemalloc_get_tracemalloc_memory_impl(module);
167 }
168 
169 PyDoc_STRVAR(_tracemalloc_get_traced_memory__doc__,
170 "get_traced_memory($module, /)\n"
171 "--\n"
172 "\n"
173 "Get the current size and peak size of memory blocks traced by tracemalloc.\n"
174 "\n"
175 "Returns a tuple: (current: int, peak: int).");
176 
177 #define _TRACEMALLOC_GET_TRACED_MEMORY_METHODDEF    \
178     {"get_traced_memory", (PyCFunction)_tracemalloc_get_traced_memory, METH_NOARGS, _tracemalloc_get_traced_memory__doc__},
179 
180 static PyObject *
181 _tracemalloc_get_traced_memory_impl(PyObject *module);
182 
183 static PyObject *
_tracemalloc_get_traced_memory(PyObject * module,PyObject * Py_UNUSED (ignored))184 _tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
185 {
186     return _tracemalloc_get_traced_memory_impl(module);
187 }
188 /*[clinic end generated code: output=d98afded69c89d52 input=a9049054013a1b77]*/
189