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)(void(*)(void))_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_CheckPositional("start", nargs, 0, 1)) {
99 goto exit;
100 }
101 if (nargs < 1) {
102 goto skip_optional;
103 }
104 nframe = _PyLong_AsInt(args[0]);
105 if (nframe == -1 && PyErr_Occurred()) {
106 goto exit;
107 }
108 skip_optional:
109 return_value = _tracemalloc_start_impl(module, nframe);
110
111 exit:
112 return return_value;
113 }
114
115 PyDoc_STRVAR(_tracemalloc_stop__doc__,
116 "stop($module, /)\n"
117 "--\n"
118 "\n"
119 "Stop tracing Python memory allocations.\n"
120 "\n"
121 "Also clear traces of memory blocks allocated by Python.");
122
123 #define _TRACEMALLOC_STOP_METHODDEF \
124 {"stop", (PyCFunction)_tracemalloc_stop, METH_NOARGS, _tracemalloc_stop__doc__},
125
126 static PyObject *
127 _tracemalloc_stop_impl(PyObject *module);
128
129 static PyObject *
_tracemalloc_stop(PyObject * module,PyObject * Py_UNUSED (ignored))130 _tracemalloc_stop(PyObject *module, PyObject *Py_UNUSED(ignored))
131 {
132 return _tracemalloc_stop_impl(module);
133 }
134
135 PyDoc_STRVAR(_tracemalloc_get_traceback_limit__doc__,
136 "get_traceback_limit($module, /)\n"
137 "--\n"
138 "\n"
139 "Get the maximum number of frames stored in the traceback of a trace.\n"
140 "\n"
141 "By default, a trace of an allocated memory block only stores\n"
142 "the most recent frame: the limit is 1.");
143
144 #define _TRACEMALLOC_GET_TRACEBACK_LIMIT_METHODDEF \
145 {"get_traceback_limit", (PyCFunction)_tracemalloc_get_traceback_limit, METH_NOARGS, _tracemalloc_get_traceback_limit__doc__},
146
147 static PyObject *
148 _tracemalloc_get_traceback_limit_impl(PyObject *module);
149
150 static PyObject *
_tracemalloc_get_traceback_limit(PyObject * module,PyObject * Py_UNUSED (ignored))151 _tracemalloc_get_traceback_limit(PyObject *module, PyObject *Py_UNUSED(ignored))
152 {
153 return _tracemalloc_get_traceback_limit_impl(module);
154 }
155
156 PyDoc_STRVAR(_tracemalloc_get_tracemalloc_memory__doc__,
157 "get_tracemalloc_memory($module, /)\n"
158 "--\n"
159 "\n"
160 "Get the memory usage in bytes of the tracemalloc module.\n"
161 "\n"
162 "This memory is used internally to trace memory allocations.");
163
164 #define _TRACEMALLOC_GET_TRACEMALLOC_MEMORY_METHODDEF \
165 {"get_tracemalloc_memory", (PyCFunction)_tracemalloc_get_tracemalloc_memory, METH_NOARGS, _tracemalloc_get_tracemalloc_memory__doc__},
166
167 static PyObject *
168 _tracemalloc_get_tracemalloc_memory_impl(PyObject *module);
169
170 static PyObject *
_tracemalloc_get_tracemalloc_memory(PyObject * module,PyObject * Py_UNUSED (ignored))171 _tracemalloc_get_tracemalloc_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
172 {
173 return _tracemalloc_get_tracemalloc_memory_impl(module);
174 }
175
176 PyDoc_STRVAR(_tracemalloc_get_traced_memory__doc__,
177 "get_traced_memory($module, /)\n"
178 "--\n"
179 "\n"
180 "Get the current size and peak size of memory blocks traced by tracemalloc.\n"
181 "\n"
182 "Returns a tuple: (current: int, peak: int).");
183
184 #define _TRACEMALLOC_GET_TRACED_MEMORY_METHODDEF \
185 {"get_traced_memory", (PyCFunction)_tracemalloc_get_traced_memory, METH_NOARGS, _tracemalloc_get_traced_memory__doc__},
186
187 static PyObject *
188 _tracemalloc_get_traced_memory_impl(PyObject *module);
189
190 static PyObject *
_tracemalloc_get_traced_memory(PyObject * module,PyObject * Py_UNUSED (ignored))191 _tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
192 {
193 return _tracemalloc_get_traced_memory_impl(module);
194 }
195
196 PyDoc_STRVAR(_tracemalloc_reset_peak__doc__,
197 "reset_peak($module, /)\n"
198 "--\n"
199 "\n"
200 "Set the peak size of memory blocks traced by tracemalloc to the current size.\n"
201 "\n"
202 "Do nothing if the tracemalloc module is not tracing memory allocations.");
203
204 #define _TRACEMALLOC_RESET_PEAK_METHODDEF \
205 {"reset_peak", (PyCFunction)_tracemalloc_reset_peak, METH_NOARGS, _tracemalloc_reset_peak__doc__},
206
207 static PyObject *
208 _tracemalloc_reset_peak_impl(PyObject *module);
209
210 static PyObject *
_tracemalloc_reset_peak(PyObject * module,PyObject * Py_UNUSED (ignored))211 _tracemalloc_reset_peak(PyObject *module, PyObject *Py_UNUSED(ignored))
212 {
213 return _tracemalloc_reset_peak_impl(module);
214 }
215 /*[clinic end generated code: output=bafca0a19b0b0823 input=a9049054013a1b77]*/
216