1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 PyDoc_STRVAR(gc_enable__doc__,
6 "enable($module, /)\n"
7 "--\n"
8 "\n"
9 "Enable automatic garbage collection.");
10
11 #define GC_ENABLE_METHODDEF \
12 {"enable", (PyCFunction)gc_enable, METH_NOARGS, gc_enable__doc__},
13
14 static PyObject *
15 gc_enable_impl(PyObject *module);
16
17 static PyObject *
gc_enable(PyObject * module,PyObject * Py_UNUSED (ignored))18 gc_enable(PyObject *module, PyObject *Py_UNUSED(ignored))
19 {
20 return gc_enable_impl(module);
21 }
22
23 PyDoc_STRVAR(gc_disable__doc__,
24 "disable($module, /)\n"
25 "--\n"
26 "\n"
27 "Disable automatic garbage collection.");
28
29 #define GC_DISABLE_METHODDEF \
30 {"disable", (PyCFunction)gc_disable, METH_NOARGS, gc_disable__doc__},
31
32 static PyObject *
33 gc_disable_impl(PyObject *module);
34
35 static PyObject *
gc_disable(PyObject * module,PyObject * Py_UNUSED (ignored))36 gc_disable(PyObject *module, PyObject *Py_UNUSED(ignored))
37 {
38 return gc_disable_impl(module);
39 }
40
41 PyDoc_STRVAR(gc_isenabled__doc__,
42 "isenabled($module, /)\n"
43 "--\n"
44 "\n"
45 "Returns true if automatic garbage collection is enabled.");
46
47 #define GC_ISENABLED_METHODDEF \
48 {"isenabled", (PyCFunction)gc_isenabled, METH_NOARGS, gc_isenabled__doc__},
49
50 static int
51 gc_isenabled_impl(PyObject *module);
52
53 static PyObject *
gc_isenabled(PyObject * module,PyObject * Py_UNUSED (ignored))54 gc_isenabled(PyObject *module, PyObject *Py_UNUSED(ignored))
55 {
56 PyObject *return_value = NULL;
57 int _return_value;
58
59 _return_value = gc_isenabled_impl(module);
60 if ((_return_value == -1) && PyErr_Occurred()) {
61 goto exit;
62 }
63 return_value = PyBool_FromLong((long)_return_value);
64
65 exit:
66 return return_value;
67 }
68
69 PyDoc_STRVAR(gc_collect__doc__,
70 "collect($module, /, generation=2)\n"
71 "--\n"
72 "\n"
73 "Run the garbage collector.\n"
74 "\n"
75 "With no arguments, run a full collection. The optional argument\n"
76 "may be an integer specifying which generation to collect. A ValueError\n"
77 "is raised if the generation number is invalid.\n"
78 "\n"
79 "The number of unreachable objects is returned.");
80
81 #define GC_COLLECT_METHODDEF \
82 {"collect", (PyCFunction)gc_collect, METH_FASTCALL|METH_KEYWORDS, gc_collect__doc__},
83
84 static Py_ssize_t
85 gc_collect_impl(PyObject *module, int generation);
86
87 static PyObject *
gc_collect(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)88 gc_collect(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
89 {
90 PyObject *return_value = NULL;
91 static const char * const _keywords[] = {"generation", NULL};
92 static _PyArg_Parser _parser = {"|i:collect", _keywords, 0};
93 int generation = NUM_GENERATIONS - 1;
94 Py_ssize_t _return_value;
95
96 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
97 &generation)) {
98 goto exit;
99 }
100 _return_value = gc_collect_impl(module, generation);
101 if ((_return_value == -1) && PyErr_Occurred()) {
102 goto exit;
103 }
104 return_value = PyLong_FromSsize_t(_return_value);
105
106 exit:
107 return return_value;
108 }
109
110 PyDoc_STRVAR(gc_set_debug__doc__,
111 "set_debug($module, flags, /)\n"
112 "--\n"
113 "\n"
114 "Set the garbage collection debugging flags.\n"
115 "\n"
116 " flags\n"
117 " An integer that can have the following bits turned on:\n"
118 " DEBUG_STATS - Print statistics during collection.\n"
119 " DEBUG_COLLECTABLE - Print collectable objects found.\n"
120 " DEBUG_UNCOLLECTABLE - Print unreachable but uncollectable objects\n"
121 " found.\n"
122 " DEBUG_SAVEALL - Save objects to gc.garbage rather than freeing them.\n"
123 " DEBUG_LEAK - Debug leaking programs (everything but STATS).\n"
124 "\n"
125 "Debugging information is written to sys.stderr.");
126
127 #define GC_SET_DEBUG_METHODDEF \
128 {"set_debug", (PyCFunction)gc_set_debug, METH_O, gc_set_debug__doc__},
129
130 static PyObject *
131 gc_set_debug_impl(PyObject *module, int flags);
132
133 static PyObject *
gc_set_debug(PyObject * module,PyObject * arg)134 gc_set_debug(PyObject *module, PyObject *arg)
135 {
136 PyObject *return_value = NULL;
137 int flags;
138
139 if (!PyArg_Parse(arg, "i:set_debug", &flags)) {
140 goto exit;
141 }
142 return_value = gc_set_debug_impl(module, flags);
143
144 exit:
145 return return_value;
146 }
147
148 PyDoc_STRVAR(gc_get_debug__doc__,
149 "get_debug($module, /)\n"
150 "--\n"
151 "\n"
152 "Get the garbage collection debugging flags.");
153
154 #define GC_GET_DEBUG_METHODDEF \
155 {"get_debug", (PyCFunction)gc_get_debug, METH_NOARGS, gc_get_debug__doc__},
156
157 static int
158 gc_get_debug_impl(PyObject *module);
159
160 static PyObject *
gc_get_debug(PyObject * module,PyObject * Py_UNUSED (ignored))161 gc_get_debug(PyObject *module, PyObject *Py_UNUSED(ignored))
162 {
163 PyObject *return_value = NULL;
164 int _return_value;
165
166 _return_value = gc_get_debug_impl(module);
167 if ((_return_value == -1) && PyErr_Occurred()) {
168 goto exit;
169 }
170 return_value = PyLong_FromLong((long)_return_value);
171
172 exit:
173 return return_value;
174 }
175
176 PyDoc_STRVAR(gc_get_threshold__doc__,
177 "get_threshold($module, /)\n"
178 "--\n"
179 "\n"
180 "Return the current collection thresholds.");
181
182 #define GC_GET_THRESHOLD_METHODDEF \
183 {"get_threshold", (PyCFunction)gc_get_threshold, METH_NOARGS, gc_get_threshold__doc__},
184
185 static PyObject *
186 gc_get_threshold_impl(PyObject *module);
187
188 static PyObject *
gc_get_threshold(PyObject * module,PyObject * Py_UNUSED (ignored))189 gc_get_threshold(PyObject *module, PyObject *Py_UNUSED(ignored))
190 {
191 return gc_get_threshold_impl(module);
192 }
193
194 PyDoc_STRVAR(gc_get_count__doc__,
195 "get_count($module, /)\n"
196 "--\n"
197 "\n"
198 "Return a three-tuple of the current collection counts.");
199
200 #define GC_GET_COUNT_METHODDEF \
201 {"get_count", (PyCFunction)gc_get_count, METH_NOARGS, gc_get_count__doc__},
202
203 static PyObject *
204 gc_get_count_impl(PyObject *module);
205
206 static PyObject *
gc_get_count(PyObject * module,PyObject * Py_UNUSED (ignored))207 gc_get_count(PyObject *module, PyObject *Py_UNUSED(ignored))
208 {
209 return gc_get_count_impl(module);
210 }
211
212 PyDoc_STRVAR(gc_get_objects__doc__,
213 "get_objects($module, /)\n"
214 "--\n"
215 "\n"
216 "Return a list of objects tracked by the collector (excluding the list returned).");
217
218 #define GC_GET_OBJECTS_METHODDEF \
219 {"get_objects", (PyCFunction)gc_get_objects, METH_NOARGS, gc_get_objects__doc__},
220
221 static PyObject *
222 gc_get_objects_impl(PyObject *module);
223
224 static PyObject *
gc_get_objects(PyObject * module,PyObject * Py_UNUSED (ignored))225 gc_get_objects(PyObject *module, PyObject *Py_UNUSED(ignored))
226 {
227 return gc_get_objects_impl(module);
228 }
229
230 PyDoc_STRVAR(gc_get_stats__doc__,
231 "get_stats($module, /)\n"
232 "--\n"
233 "\n"
234 "Return a list of dictionaries containing per-generation statistics.");
235
236 #define GC_GET_STATS_METHODDEF \
237 {"get_stats", (PyCFunction)gc_get_stats, METH_NOARGS, gc_get_stats__doc__},
238
239 static PyObject *
240 gc_get_stats_impl(PyObject *module);
241
242 static PyObject *
gc_get_stats(PyObject * module,PyObject * Py_UNUSED (ignored))243 gc_get_stats(PyObject *module, PyObject *Py_UNUSED(ignored))
244 {
245 return gc_get_stats_impl(module);
246 }
247
248 PyDoc_STRVAR(gc_is_tracked__doc__,
249 "is_tracked($module, obj, /)\n"
250 "--\n"
251 "\n"
252 "Returns true if the object is tracked by the garbage collector.\n"
253 "\n"
254 "Simple atomic objects will return false.");
255
256 #define GC_IS_TRACKED_METHODDEF \
257 {"is_tracked", (PyCFunction)gc_is_tracked, METH_O, gc_is_tracked__doc__},
258
259 PyDoc_STRVAR(gc_freeze__doc__,
260 "freeze($module, /)\n"
261 "--\n"
262 "\n"
263 "Freeze all current tracked objects and ignore them for future collections.\n"
264 "\n"
265 "This can be used before a POSIX fork() call to make the gc copy-on-write friendly.\n"
266 "Note: collection before a POSIX fork() call may free pages for future allocation\n"
267 "which can cause copy-on-write.");
268
269 #define GC_FREEZE_METHODDEF \
270 {"freeze", (PyCFunction)gc_freeze, METH_NOARGS, gc_freeze__doc__},
271
272 static PyObject *
273 gc_freeze_impl(PyObject *module);
274
275 static PyObject *
gc_freeze(PyObject * module,PyObject * Py_UNUSED (ignored))276 gc_freeze(PyObject *module, PyObject *Py_UNUSED(ignored))
277 {
278 return gc_freeze_impl(module);
279 }
280
281 PyDoc_STRVAR(gc_unfreeze__doc__,
282 "unfreeze($module, /)\n"
283 "--\n"
284 "\n"
285 "Unfreeze all objects in the permanent generation.\n"
286 "\n"
287 "Put all objects in the permanent generation back into oldest generation.");
288
289 #define GC_UNFREEZE_METHODDEF \
290 {"unfreeze", (PyCFunction)gc_unfreeze, METH_NOARGS, gc_unfreeze__doc__},
291
292 static PyObject *
293 gc_unfreeze_impl(PyObject *module);
294
295 static PyObject *
gc_unfreeze(PyObject * module,PyObject * Py_UNUSED (ignored))296 gc_unfreeze(PyObject *module, PyObject *Py_UNUSED(ignored))
297 {
298 return gc_unfreeze_impl(module);
299 }
300
301 PyDoc_STRVAR(gc_get_freeze_count__doc__,
302 "get_freeze_count($module, /)\n"
303 "--\n"
304 "\n"
305 "Return the number of objects in the permanent generation.");
306
307 #define GC_GET_FREEZE_COUNT_METHODDEF \
308 {"get_freeze_count", (PyCFunction)gc_get_freeze_count, METH_NOARGS, gc_get_freeze_count__doc__},
309
310 static Py_ssize_t
311 gc_get_freeze_count_impl(PyObject *module);
312
313 static PyObject *
gc_get_freeze_count(PyObject * module,PyObject * Py_UNUSED (ignored))314 gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))
315 {
316 PyObject *return_value = NULL;
317 Py_ssize_t _return_value;
318
319 _return_value = gc_get_freeze_count_impl(module);
320 if ((_return_value == -1) && PyErr_Occurred()) {
321 goto exit;
322 }
323 return_value = PyLong_FromSsize_t(_return_value);
324
325 exit:
326 return return_value;
327 }
328 /*[clinic end generated code: output=21dc9270b10b7891 input=a9049054013a1b77]*/
329