[Python-checkins] cpython: Issue #6695: Full garbage collection runs now clear the freelist of set objects.
antoine.pitrou
python-checkins at python.org
Fri Dec 16 11:25:42 CET 2011
http://hg.python.org/cpython/rev/57f0af61da53
changeset: 73994:57f0af61da53
user: Antoine Pitrou <solipsis at pitrou.net>
date: Fri Dec 16 11:24:27 2011 +0100
summary:
Issue #6695: Full garbage collection runs now clear the freelist of set objects.
Initial patch by Matthias Troffaes.
files:
Doc/c-api/set.rst | 7 +++++++
Include/setobject.h | 2 ++
Misc/NEWS | 3 +++
Modules/gcmodule.c | 1 +
Objects/setobject.c | 12 ++++++++++--
5 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/Doc/c-api/set.rst b/Doc/c-api/set.rst
--- a/Doc/c-api/set.rst
+++ b/Doc/c-api/set.rst
@@ -157,3 +157,10 @@
.. c:function:: int PySet_Clear(PyObject *set)
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
diff --git a/Include/setobject.h b/Include/setobject.h
--- a/Include/setobject.h
+++ b/Include/setobject.h
@@ -99,6 +99,8 @@
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
+
+PyAPI_FUNC(int) PySet_ClearFreeList(void);
#endif
#ifdef __cplusplus
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
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
overriden and take additional arguments (followup to issue #12555).
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -764,6 +764,7 @@
(void)PyFloat_ClearFreeList();
(void)PyList_ClearFreeList();
(void)PyDict_ClearFreeList();
+ (void)PySet_ClearFreeList();
}
static double
diff --git a/Objects/setobject.c b/Objects/setobject.c
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1068,9 +1068,10 @@
return emptyfrozenset;
}
-void
-PySet_Fini(void)
+int
+PySet_ClearFreeList(void)
{
+ int freelist_size = numfree;
PySetObject *so;
while (numfree) {
@@ -1078,6 +1079,13 @@
so = free_list[numfree];
PyObject_GC_Del(so);
}
+ return freelist_size;
+}
+
+void
+PySet_Fini(void)
+{
+ PySet_ClearFreeList();
Py_CLEAR(dummy);
Py_CLEAR(emptyfrozenset);
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list