- New C API PyGC_Collect(), same as calling gc.collect().
- Call this in Py_Finalize(). - Expand the Misc/NEWS text on PY_LONG_LONG.
This commit is contained in:
parent
cf8d285ba3
commit
e13ddc9ec8
|
@ -228,6 +228,9 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, int);
|
||||||
* ==========================
|
* ==========================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* C equivalent of gc.collect(). */
|
||||||
|
long PyGC_Collect(void);
|
||||||
|
|
||||||
/* Test if a type has a GC head */
|
/* Test if a type has a GC head */
|
||||||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
||||||
|
|
||||||
|
|
|
@ -169,11 +169,17 @@ Build
|
||||||
C API
|
C API
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
- Added PyGC_Collect(), equivalent to calling gc.collect().
|
||||||
|
|
||||||
- PyThreadState_GetDict() was changed not to raise an exception or
|
- PyThreadState_GetDict() was changed not to raise an exception or
|
||||||
issue a fatal error when no current thread state is available. This
|
issue a fatal error when no current thread state is available. This
|
||||||
makes it possible to print dictionaries when no thread is active.
|
makes it possible to print dictionaries when no thread is active.
|
||||||
|
|
||||||
- LONG_LONG was renamed to PY_LONG_LONG.
|
- LONG_LONG was renamed to PY_LONG_LONG. Extensions that use this and
|
||||||
|
need compatibility with previous versions can use this:
|
||||||
|
#ifndef PY_LONG_LONG
|
||||||
|
#define PY_LONG_LONG LONG_LONG
|
||||||
|
#endif
|
||||||
|
|
||||||
- Added PyObject_SelfIter() to fill the tp_iter slot for the
|
- Added PyObject_SelfIter() to fill the tp_iter slot for the
|
||||||
typical case where the method returns its self argument.
|
typical case where the method returns its self argument.
|
||||||
|
|
|
@ -980,8 +980,26 @@ initgc(void)
|
||||||
#undef ADD_INT
|
#undef ADD_INT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* API to invoke gc.collect() from C */
|
||||||
|
long
|
||||||
|
PyGC_Collect(void)
|
||||||
|
{
|
||||||
|
long n;
|
||||||
|
|
||||||
|
if (collecting)
|
||||||
|
n = 0; /* already collecting, don't do anything */
|
||||||
|
else {
|
||||||
|
collecting = 1;
|
||||||
|
n = collect(NUM_GENERATIONS - 1);
|
||||||
|
collecting = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
/* for debugging */
|
/* for debugging */
|
||||||
void _PyGC_Dump(PyGC_Head *g)
|
void
|
||||||
|
_PyGC_Dump(PyGC_Head *g)
|
||||||
{
|
{
|
||||||
_PyObject_Dump(FROM_GC(g));
|
_PyObject_Dump(FROM_GC(g));
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,9 +255,17 @@ Py_Finalize(void)
|
||||||
Py_XDECREF(PyModule_WarningsModule);
|
Py_XDECREF(PyModule_WarningsModule);
|
||||||
PyModule_WarningsModule = NULL;
|
PyModule_WarningsModule = NULL;
|
||||||
|
|
||||||
|
/* Collect garbage. This may call finalizers; it's nice to call these
|
||||||
|
before all modules are destroyed. */
|
||||||
|
PyGC_Collect();
|
||||||
|
|
||||||
/* Destroy all modules */
|
/* Destroy all modules */
|
||||||
PyImport_Cleanup();
|
PyImport_Cleanup();
|
||||||
|
|
||||||
|
/* Collect final garbage. This disposes of cycles created by
|
||||||
|
new-style class definitions, for example. */
|
||||||
|
PyGC_Collect();
|
||||||
|
|
||||||
/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
|
/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
|
||||||
_PyImport_Fini();
|
_PyImport_Fini();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue