[Python-Dev] RE: test_sort.py failure (original) (raw)

Armin Rigo arigo at tunes.org
Fri Jul 30 05:02:49 CEST 2004


Hello Raymond,

On Thu, Jul 29, 2004 at 06:06:19AM -0400, Raymond Hettinger wrote:

> > * listassslice() should add a line to maintain them, > > * listresize() can drop the test for obitem != NULL, and

Will put these in.

I think the list_ass_slice() modification you are thinking about is obsolete since the check-in I documented in my latest e-mail.

list_resize() dropping the test for ob_item != NULL looks like a sane plan: the only C extensions that I can think of that could break would be the ones that for extreme performance hacking don't use PyList_SetSlice() to clear a list, but directly zero out ob_size and ob_item -- which is a real bad thing to do.

About clearing lists efficiently: what about adding PyList_Clear() to the public API? It's clearer than the current

PyList_SetSlice(lst, 0, PyList_GET_SIZE(lst), (PyObject *)NULL)

(which BTW could fail with a MemoryError up to yesterday; I bet not all users of this idiom were aware of that. There was even an example of not checking the return value in listobject.c itself!) By contrast, PyList_Clear(), like list_clear(), would never fail and could return void.

A bientot,

Armin.



More information about the Python-Dev mailing list