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

Guido van Rossum guido at python.org
Thu Jul 29 20:11:08 CEST 2004


The following (just checked in) changes should solve the problem:

* drop the unreasonable list invariant that obitem should never come back to NULL during the lifetime of the object. * listobject.c nevertheless did not conform to the other invariants, either; fixed. * listobject.c now uses listclear() as the obvious internal way to clear a list, instead of abusing listassslice() for that. It makes it easier to enforce the invariant about obitem == NULL. * listsort() sets allocated to -1 during sort; any mutation will set it to a value >= 0, so it is a safe way to detect mutation. A negative value for allocated does not cause a problem elsewhere currently. testsort.py has a new test for this fix. * listsort() leak: if items were added to the list during the sort, AND if these items had a del that puts still more stuff into the list, then this more stuff (and the PyObject** array to hold them) were overridden at the end of listsort() and never released.

Wow. I'm impressed. Thanks!

BTW, I just wrote a little programing for playing Conway's Game of Life, using Tkinter. (Yes, I was inspired by Damien Conway's (no relation) talk Tuesday night at OSCON.) Anyway, it runs at about 5.35 generations/second in Python 2.3, and 6.35 generations/second in Python 2.4. Good job everyone!

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list