blob: 2950051b14daf7387326b22aa054265ac466e06f [file] [log] [blame]
Serhiy Storchakab451f912017-02-04 12:18:38 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_tracemalloc_is_tracing__doc__,
6"is_tracing($module, /)\n"
7"--\n"
8"\n"
Serhiy Storchaka97353842017-02-05 22:58:46 +02009"Return True if the tracemalloc module is tracing Python memory allocations.");
Serhiy Storchakab451f912017-02-04 12:18:38 +020010
11#define _TRACEMALLOC_IS_TRACING_METHODDEF \
12 {"is_tracing", (PyCFunction)_tracemalloc_is_tracing, METH_NOARGS, _tracemalloc_is_tracing__doc__},
13
14static PyObject *
15_tracemalloc_is_tracing_impl(PyObject *module);
16
17static PyObject *
18_tracemalloc_is_tracing(PyObject *module, PyObject *Py_UNUSED(ignored))
19{
20 return _tracemalloc_is_tracing_impl(module);
21}
22
23PyDoc_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
32static PyObject *
33_tracemalloc_clear_traces_impl(PyObject *module);
34
35static PyObject *
36_tracemalloc_clear_traces(PyObject *module, PyObject *Py_UNUSED(ignored))
37{
38 return _tracemalloc_clear_traces_impl(module);
39}
40
41PyDoc_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
55static PyObject *
56_tracemalloc__get_traces_impl(PyObject *module);
57
58static PyObject *
59_tracemalloc__get_traces(PyObject *module, PyObject *Py_UNUSED(ignored))
60{
61 return _tracemalloc__get_traces_impl(module);
62}
63
64PyDoc_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
77PyDoc_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
89static PyObject *
90_tracemalloc_start_impl(PyObject *module, Py_ssize_t nframe);
91
92static PyObject *
93_tracemalloc_start(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
94{
95 PyObject *return_value = NULL;
96 Py_ssize_t nframe = 1;
97
98 if (!_PyArg_ParseStack(args, nargs, "|n:start",
99 &nframe)) {
100 goto exit;
101 }
102
103 if (!_PyArg_NoStackKeywords("start", kwnames)) {
104 goto exit;
105 }
106 return_value = _tracemalloc_start_impl(module, nframe);
107
108exit:
109 return return_value;
110}
111
112PyDoc_STRVAR(_tracemalloc_stop__doc__,
113"stop($module, /)\n"
114"--\n"
115"\n"
116"Stop tracing Python memory allocations.\n"
117"\n"
118"Also clear traces of memory blocks allocated by Python.");
119
120#define _TRACEMALLOC_STOP_METHODDEF \
121 {"stop", (PyCFunction)_tracemalloc_stop, METH_NOARGS, _tracemalloc_stop__doc__},
122
123static PyObject *
124_tracemalloc_stop_impl(PyObject *module);
125
126static PyObject *
127_tracemalloc_stop(PyObject *module, PyObject *Py_UNUSED(ignored))
128{
129 return _tracemalloc_stop_impl(module);
130}
131
132PyDoc_STRVAR(_tracemalloc_get_traceback_limit__doc__,
133"get_traceback_limit($module, /)\n"
134"--\n"
135"\n"
136"Get the maximum number of frames stored in the traceback of a trace.\n"
137"\n"
138"By default, a trace of an allocated memory block only stores\n"
139"the most recent frame: the limit is 1.");
140
141#define _TRACEMALLOC_GET_TRACEBACK_LIMIT_METHODDEF \
142 {"get_traceback_limit", (PyCFunction)_tracemalloc_get_traceback_limit, METH_NOARGS, _tracemalloc_get_traceback_limit__doc__},
143
144static PyObject *
145_tracemalloc_get_traceback_limit_impl(PyObject *module);
146
147static PyObject *
148_tracemalloc_get_traceback_limit(PyObject *module, PyObject *Py_UNUSED(ignored))
149{
150 return _tracemalloc_get_traceback_limit_impl(module);
151}
152
153PyDoc_STRVAR(_tracemalloc_get_tracemalloc_memory__doc__,
154"get_tracemalloc_memory($module, /)\n"
155"--\n"
156"\n"
157"Get the memory usage in bytes of the tracemalloc module.\n"
158"\n"
159"This memory is used internally to trace memory allocations.");
160
161#define _TRACEMALLOC_GET_TRACEMALLOC_MEMORY_METHODDEF \
162 {"get_tracemalloc_memory", (PyCFunction)_tracemalloc_get_tracemalloc_memory, METH_NOARGS, _tracemalloc_get_tracemalloc_memory__doc__},
163
164static PyObject *
165_tracemalloc_get_tracemalloc_memory_impl(PyObject *module);
166
167static PyObject *
168_tracemalloc_get_tracemalloc_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
169{
170 return _tracemalloc_get_tracemalloc_memory_impl(module);
171}
172
173PyDoc_STRVAR(_tracemalloc_get_traced_memory__doc__,
174"get_traced_memory($module, /)\n"
175"--\n"
176"\n"
177"Get the current size and peak size of memory blocks traced by tracemalloc.\n"
178"\n"
179"Returns a tuple: (current: int, peak: int).");
180
181#define _TRACEMALLOC_GET_TRACED_MEMORY_METHODDEF \
182 {"get_traced_memory", (PyCFunction)_tracemalloc_get_traced_memory, METH_NOARGS, _tracemalloc_get_traced_memory__doc__},
183
184static PyObject *
185_tracemalloc_get_traced_memory_impl(PyObject *module);
186
187static PyObject *
188_tracemalloc_get_traced_memory(PyObject *module, PyObject *Py_UNUSED(ignored))
189{
190 return _tracemalloc_get_traced_memory_impl(module);
191}
Serhiy Storchaka97353842017-02-05 22:58:46 +0200192/*[clinic end generated code: output=159ce5d627964f09 input=a9049054013a1b77]*/