[Python-Dev] Proposal to eliminate PySet_Fini
jack at psynchronous.com
Tue Jun 27 20:44:05 CEST 2006
On Tue, Jun 27, 2006 at 02:09:19PM -0400, Alexander Belopolsky wrote:
> Setobject code allocates several internal objects on the heap that are
> cleaned up by the PySet_Fini function. This is a fine design choice,
> but it often makes debugging applications with embedded python more
> I propose to eliminate the need for PySet_Fini as follows:
> 1. Make dummy and emptyfrozenset static objects similar to Py_None
> 2. Eliminate the free sets reuse scheme.
> The second proposal is probably more controversial, but is there any
> real benefit from that scheme when pymalloc is enabled?
These are optimizations and not likely to go away. tuples especially get
reused frequently. In the case of tuples you can #define MAXSAVEDTUPLES
to zero in a custom python build to disable free-listing. You can submit
a patch that #ifdef'd the other free list in a similar way (sets don't
currently have the ifdef check, for instance) and hope it gets accepted.
I don't see why it wouldn't.
PyObject_MALLOC does a good job of reusing small allocations but it
can't quite manage the same speed as a free list, especially for things that
have some extra setup involved (tuples have a free list for each length).
More information about the Python-Dev