changeset: 73994:57f0af61da53 user: Antoine Pitrou date: Fri Dec 16 11:24:27 2011 +0100 files: Doc/c-api/set.rst Include/setobject.h Misc/NEWS Modules/gcmodule.c Objects/setobject.c description: Issue #6695: Full garbage collection runs now clear the freelist of set objects. Initial patch by Matthias Troffaes. diff -r 8d6d068e9966 -r 57f0af61da53 Doc/c-api/set.rst --- a/Doc/c-api/set.rst Thu Dec 15 19:24:49 2011 -0500 +++ b/Doc/c-api/set.rst Fri Dec 16 11:24:27 2011 +0100 @@ -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 -r 8d6d068e9966 -r 57f0af61da53 Include/setobject.h --- a/Include/setobject.h Thu Dec 15 19:24:49 2011 -0500 +++ b/Include/setobject.h Fri Dec 16 11:24:27 2011 +0100 @@ -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 -r 8d6d068e9966 -r 57f0af61da53 Misc/NEWS --- a/Misc/NEWS Thu Dec 15 19:24:49 2011 -0500 +++ b/Misc/NEWS Fri Dec 16 11:24:27 2011 +0100 @@ -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 -r 8d6d068e9966 -r 57f0af61da53 Modules/gcmodule.c --- a/Modules/gcmodule.c Thu Dec 15 19:24:49 2011 -0500 +++ b/Modules/gcmodule.c Fri Dec 16 11:24:27 2011 +0100 @@ -764,6 +764,7 @@ (void)PyFloat_ClearFreeList(); (void)PyList_ClearFreeList(); (void)PyDict_ClearFreeList(); + (void)PySet_ClearFreeList(); } static double diff -r 8d6d068e9966 -r 57f0af61da53 Objects/setobject.c --- a/Objects/setobject.c Thu Dec 15 19:24:49 2011 -0500 +++ b/Objects/setobject.c Fri Dec 16 11:24:27 2011 +0100 @@ -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); }

AltStyle によって変換されたページ (->オリジナル) /