On Tue, Nov 9, 2021 at 11:05 PM Paul Bryan <pbr...@anode.ca> wrote: > On Tue, Nov 09, 2021 at 10:01:35PM -0800, Christopher Barker wrote: > > What are use cases for sorted dicts? > > Good question :-)
It could be handy for deterministic iteration of its values, for example to > allow serialized values to be easily compared, or to generate and verify a > signatures. > Yup -- I've done that. But for that, it's fine to sort when you are doing the comparing / serialization. What I haven't been able to imagine is a use case for keeping a Mapping sorted constantly as you insert / remove items. For that you'd need a use case where you were making sorted queries of various sorts. I noticed, for instance, that the Java implementation posted earlier had methods like "all the items after this one" (can't remember how that was spelled). I'm sure there are use cases for this, I'm probably lacking imagination :-) -CHB -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ 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/X7CGUBYQ3PEIYNMYAG3Z4SMXWILR5BKT/ Code of Conduct: http://python.org/psf/codeofconduct/