Author jeff.allen
Recipients jamesmudd, jeff.allen, stefan.richthofer, zyasoft
Date 2017-03-19.10:49:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
A little more investigation shows that (for arrays that are not small, and in some circumstances) TimSort makes use of an auxilliary array that it will copy back into the main array in a merge-sort, doing comparisons along the way.

In Java, if one of those comparisons blows up part-way through a merge, the stack unwinds from there, and the copy that might have occurred is omitted:

In CPython, when an exception is raised, the sorting is abandoned, but the merge function keeps its promise to put the elements back into the main array, here:

I can't find where either language promises not to mess up your list in these circumstances, so arguably test_sort is asking too much. But we like to do the same as CPython if we can. I don't like the obvious answer: preserve and restore the original list, doing more than CPython at considerable cost in memory. I think it follows logically that we would have to conceal the exception raised in the comparator, to let the Java sort run to completion somehow, then rethrow it.
Date User Action Args
2017-03-19 10:49:31jeff.allensetmessageid: <>
2017-03-19 10:49:31jeff.allensetrecipients: + jeff.allen, zyasoft, stefan.richthofer, jamesmudd
2017-03-19 10:49:31jeff.allenlinkissue2399 messages
2017-03-19 10:49:30jeff.allencreate