[Python-Dev] Re: Should set objects maintain insertion order too?

2019年12月27日 02:14:18 -0800

On 2019年12月24日 12:08:33 +0900
"Stephen J. Turnbull" <[email protected]> wrote:
> David Mertz writes:
> 
> > Even though I was the first person in this thread to suggest
> > collections.OrderedSet, I'm "meh" about it now. As I read more and played
> > with the sortedcollections package, it seemed to me that while I might want
> > a set that iterated in a determinate and meaningful order moderately often,
> > insertion order would make up a small share of those use cases. 
> 
> On the other hand, insertion order is one of the most prominent of the
> determinate meaningful orders where you would have to do ugly things
> to use "sorted" to get that order. Any application where you have an
> unreliable message bus feeding a queue (so that you might get
> duplicate objects but it's bad to process the same object twice) would
> be a potential application of insertion-ordered sets.
In that case you probably want a separate persistent "seen" set.
Because your queue can have been drained by the time a duplicate object
arrives.
(which means you probably want something more efficient, such as a
sequence number)
Regards
Antoine.
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/QANSVP7LU4OVMGKIGM25CJ4W24YYYVBD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to