When convert two sets with the same elements to lists, are the lists always going to be the same?

Dan Stromberg drsalists at gmail.com
Thu May 3 20:56:40 EDT 2012


If you need the same ordering in two lists, you really should sort the
lists - though your comparison function need not be that traditional.  You
might be able to get away with not sorting sometimes, but on CPython
upgrades or using different Python interpreters (Pypy, Jython), it's almost
certain the ordering will be allowed to change.

But sorting in a loop is not generally a good thing - there's almost always
a better alternative.

On Thu, May 3, 2012 at 5:36 PM, Peng Yu <pengyu.ut at gmail.com> wrote:

> Hi,
>
> list(a_set)
>
> When convert two sets with the same elements to two lists, are the
> lists always going to be the same (i.e., the elements in each list are
> ordered the same)? Is it documented anywhere?
>
> --
> Regards,
> Peng
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120503/14a2781a/attachment.html>


More information about the Python-list mailing list