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