[issue14775] Dict untracking can result in quadratic dict build-up

Antoine Pitrou report at bugs.python.org
Wed May 23 18:26:05 CEST 2012


Antoine Pitrou <pitrou at free.fr> added the comment:

Le mercredi 23 mai 2012 à 16:22 +0000, stw a écrit :
> So the tuple is linked-in to the garbage collection list before its
> contents are constructed?

It is. It typically happens when you do (in C code):

PyObject *my_tuple = PyTuple_New(2);
/* compute some_object ... */
PyTuple_SET_ITEM(my_tuple, 0, some_object);
/* compute some_other_object ... */
PyTuple_SET_ITEM(my_tuple, 1, some_other_object);

> Could tuples not be untracked at creation time then, or do not enough
> survive to gc to make this worthwhile?

The latter. Also, tuples are created at a high rate in the interpreter,
so it can actually decrease performance.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14775>
_______________________________________


More information about the Python-bugs-list mailing list