Google: "python more collections pypi"
gets quite a few hits -- I haven't checked out any of them though. Depending on a third party package does take some thought -- but for something like this you could simply "vendor" a particular class (i.e. include the code with yours). Totally different topic, but I do think that a "curated" package repo would be helpful -- there is a lot of cruft on PyPi :-( -CHB On Fri, Jun 30, 2023 at 3:47 AM Dom Grigonis <dom.grigo...@gmail.com> wrote: > In my experience, the implementation of bijective dict is largely > application specific. > > 1. Unique-valued dict is fairly straight forward and there is little > ambiguity on implementation using 2 dicts. > 2. However, if values are not to be unique, then it largely depends on > application. (best (as in most efficient) pypi I have found for this: > https://pypi.org/project/indexed/) > > But to me it feels that there is some sort of gap in container space. E.g. I > have spent a reasonable amount of time on: > a) 1-2-1 dict > b) many-2-many dict > c) dict-deque > d) bijective-dict-deque > e) list-dict > > Maybe it would be good to have similar package to `more_itertools`. E.g. > `more_collections`, where assorted recipes are implemented. > > I am not a fan of making my libraries dependent on less known pypi > packages, but when a package is referenced in python official docs, then I > am much more at ease. > > > On 30 Jun 2023, at 04:50, Andre Delfino <adelf...@gmail.com> wrote: > > A dict method to retrieve the key of a value from a bijective dict would > have come in handy to me in several occasions: > > names = {'one': 1} > names.inverse()[1] > > 'one' > > names = {'one': 1, 'uno': 1} > names.inverse()[1] > > ValueError: dict is not bijective > > My usual use case is when both keys and values have simple types like > int/str, like: > > { > 'account-a': 123, > 'account-b': 456, > } > > Users may enter the account name, or the ID. The system works with the > account ID (translating from the account name if needed), but when it needs > to mention the account to the user, it shows the account name instead. > > I do understand that retrieval wouldn't be O(1). > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/BWMIASE5YCDETFSZYAUG7TVWTMBFHKQW/ > Code of Conduct: http://python.org/psf/codeofconduct/ > > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/DPZMOAICSV2YKBYWFSW36LW5GSPZFRNK/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/6G26LGITB4UPWA7C6LJ627HU7RNG5GVJ/ Code of Conduct: http://python.org/psf/codeofconduct/