Hi Larry, sets (and mappings, ie dicts), have a common functionality among
many languages and libraries that does Not include an ordering. Already, in
CPython, there is a need to somehow indicate that insertion ordering is
being used in dicts or use OrderedDict. I am quite happy with keeping sets
as they are and coding any extra functionality required on top of this.
This aids me as I work in many languages that have their own sets and
mappings, usually without any insertion ordering.

Cheers, Paddy.


On Sun, Dec 29, 2019, 12:07 AM Larry Hastings <la...@hastings.org> wrote:

>
> On 12/27/19 7:44 PM, Tim Peters wrote:
>
> [Nick Coghlan <ncogh...@gmail.com> <ncogh...@gmail.com>]
>
> I took Larry's request a slightly different way: he has a use case where
> he wants order preservation (so built in sets aren't good), but combined
> with low cost duplicate identification and elimination and removal of
> arbitrary elements (so lists and collections.deque aren't good). Organising
> a work queue that way seems common enough ...
>
>
> Is it?  I confess I haven't thought of a plausible use case.  Larry
> didn't really explain his problem, just suggested that an ordered set
> would be "a solution" to it.
>
>
> Here is the original description of my problem, from the original email in
> this thread.  I considered this an adequate explanation of my problem at
> the time.
>
>
> On 12/15/19 6:48 PM, Larry Hastings wrote:
>
> I do have a use case for this. In one project I maintain a "ready" list of
> jobs; I need to iterate over it, but I also want fast lookup because I
> soemtimes remove jobs when they're subsequently marked "not ready".  The
> existing set object would work fine here, except that it doesn't maintain
> insertion order.  That means multiple runs of the program with the same
> inputs may result in running jobs in different orders, and this instability
> makes debugging more difficult.  I've therefore switched from a set to a
> dict with all keys mapped to None, which provides all the set-like
> functionality I need.
>
>
> In subsequent emails I've clarified that my workloads are small
> enough--and computers are fast enough--that almost any data structure would
> work fine for me here, e.g. a list.  I don't think my needs should drive
> the decision making process regardless.  I only described my problem to get
> the conversation rolling.
>
> I opine that anybody who iterates over set objects and has bugs in their
> code would appreciate set objects maintaining insertion order.  I suspect
> it would make their debugging easier, because given identical inputs their
> set iteration would behave identically, thus making their bugs that much
> more stable.  That's as much use case as I have for the feature.
>
>
> */arry*
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/XWTP7OD4UMGL7DLVABM3S2CB26LN5RBP/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/AETTJXQYXYKFZOWT2CMGC6N6DAXWUCGM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to