On Sat, Aug 1, 2020 at 10:19 AM Wes Turner <wes.turner@gmail.com> wrote:
AFAIU, direct subscripting / addressing was not a use case in the design phase of the current dict?
Nope, -- if it were, it would have presumably been implemented :-) But order-preserving wasn't really a design goal either, as I understand it, but rather a side effect of the implementation. As I recall the conversation, In 3.7, when it was made "official", even then it was less about how useful it was than that people WILL use it, and will count on it, even if they are told by the docs that they shouldn't. So we might as well commit to it. And it is indeed handy now and again. So the current conversion is the result that once we have order preserving dicts, maybe we can do a few other things with them, than a use case driving the decision in the first place. On Fri, Jul 31, 2020 at 6:35 PM Inada Naoki <songofacandy@gmail.com> wrote:
There are two major points to optimize.
* Iterating over `next(islice(dict.items(), n, n+1))` will produce n temporary tuples. * (CPython implementation detail) dict can detect if there is no hole. index access is O(1) if there is no hole.
Any thoughts on how much of a difference these might make? particularly the first one. the seconds of course won't help when there are holes, which would make performance harder to predict. -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython