[Python-Dev] set iteration order
Terry Reedy
tjreedy at udel.edu
Sat Feb 26 18:25:20 CET 2011
On 2/26/2011 4:09 AM, Hagen Fürstenau wrote:
> Hi,
>
> I just hunted down a change in behaviour between Python 3.1 and 3.2 to
> possibly changed iteration order of sets due to the optimization in
> issue #8685. Of course, this order shouldn't be relied on in the first
> place, but the side effect of the optimization might be worth mentioning
> in "What's new", maybe also pointing out that the old behaviour can be
> simulated with {x for x in a if x not in b} in place of "a-b".
-1
Code with any dependence on the iteration order of unordered collections
(other than the guarantee that d.keys() and d.values() match at any
given time as long as d is unchanged) is buggy.
It is not the place of What's new to cater to buggy code.
Besides which, there is no guarantee that the 'x in a' part of the
suggestion will will remain the same from version to version or even
from run to run.
--
Terry Jan Reedy
More information about the Python-Dev
mailing list