mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #6695: Full garbage collection runs now clear the freelist of set objects.
Initial patch by Matthias Troffaes.
This commit is contained in:
parent
c144a93e98
commit
093ce9cd8c
5 changed files with 23 additions and 2 deletions
|
@ -157,3 +157,10 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
|
||||||
.. c:function:: int PySet_Clear(PyObject *set)
|
.. c:function:: int PySet_Clear(PyObject *set)
|
||||||
|
|
||||||
Empty an existing set of all elements.
|
Empty an existing set of all elements.
|
||||||
|
|
||||||
|
|
||||||
|
.. c:function:: int PySet_ClearFreeList()
|
||||||
|
|
||||||
|
Clear the free list. Return the total number of freed items.
|
||||||
|
|
||||||
|
.. versionadded:: 3.3
|
||||||
|
|
|
@ -99,6 +99,8 @@ PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key,
|
||||||
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
|
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
|
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
|
||||||
|
|
||||||
|
PyAPI_FUNC(int) PySet_ClearFreeList(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #6695: Full garbage collection runs now clear the freelist of set
|
||||||
|
objects. Initial patch by Matthias Troffaes.
|
||||||
|
|
||||||
- Fix OSError.__init__ and OSError.__new__ so that each of them can be
|
- Fix OSError.__init__ and OSError.__new__ so that each of them can be
|
||||||
overriden and take additional arguments (followup to issue #12555).
|
overriden and take additional arguments (followup to issue #12555).
|
||||||
|
|
||||||
|
|
|
@ -764,6 +764,7 @@ clear_freelists(void)
|
||||||
(void)PyFloat_ClearFreeList();
|
(void)PyFloat_ClearFreeList();
|
||||||
(void)PyList_ClearFreeList();
|
(void)PyList_ClearFreeList();
|
||||||
(void)PyDict_ClearFreeList();
|
(void)PyDict_ClearFreeList();
|
||||||
|
(void)PySet_ClearFreeList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
|
|
|
@ -1068,9 +1068,10 @@ frozenset_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
return emptyfrozenset;
|
return emptyfrozenset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
PySet_Fini(void)
|
PySet_ClearFreeList(void)
|
||||||
{
|
{
|
||||||
|
int freelist_size = numfree;
|
||||||
PySetObject *so;
|
PySetObject *so;
|
||||||
|
|
||||||
while (numfree) {
|
while (numfree) {
|
||||||
|
@ -1078,6 +1079,13 @@ PySet_Fini(void)
|
||||||
so = free_list[numfree];
|
so = free_list[numfree];
|
||||||
PyObject_GC_Del(so);
|
PyObject_GC_Del(so);
|
||||||
}
|
}
|
||||||
|
return freelist_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PySet_Fini(void)
|
||||||
|
{
|
||||||
|
PySet_ClearFreeList();
|
||||||
Py_CLEAR(dummy);
|
Py_CLEAR(dummy);
|
||||||
Py_CLEAR(emptyfrozenset);
|
Py_CLEAR(emptyfrozenset);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue