<div class="gmail_quote">2011/12/12 Victor Stinner <span dir="ltr">&lt;<a href="mailto:victor.stinner@haypocalc.com">victor.stinner@haypocalc.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
&quot;When sorting a list using the sort() method, attempting to inspect or mutate the content of the list will result in undefined behaviour.&quot;</blockquote></div><br>But is this even true? in listobject.c::listsort(), since 2002,<div>
<div><div>/* The list is temporarily made empty, so that mutations performed</div><div> * by comparison functions can&#39;t affect the slice of memory we&#39;re</div><div> * sorting (allowing mutations during sorting is a core-dump</div>
<div> * factory, since ob_item may change).</div><div> */</div><div>So behaviour is not undefined at all... maybe this report is only based on note #10 of the documentation:</div><div><a href="http://docs.python.org/library/stdtypes.html#mutable-sequence-types">http://docs.python.org/library/stdtypes.html#mutable-sequence-types</a></div>
<div>and only considers python 2.2 or older...</div><div><br></div>-- <br>Amaury Forgeot d&#39;Arc<br>
</div></div>