[Python-ideas] Why does BoundArguments use an OrderedDict?

Wes Turner wes.turner at gmail.com
Thu Dec 18 18:01:00 CET 2014


On Thu, Dec 18, 2014 at 10:27 AM, <random832 at fastmail.us> wrote:
>
>
>
> On Thu, Dec 18, 2014, at 11:18, Wes Turner wrote:
> > > Would it be reasonable to make a lightweight "predictable dict" class
> > > that makes a weaker guarantee, e.g. that the enumeration order will
> > > match the insertion order in the case where it is filled from empty
> with
> > > no intervening deletions and not guaranteed in any other cases?
> >
> > Something like DefaultOrderedDict (like defaultdict)?
> >
> > From http://bugs.python.org/issue16991#msg232825 :
> >
> > > Would this make it easy/faster to also have a DefaultOrderedDict
> > > (which can/could also be accomplished with
> > > .get(attr, []) and .setdefault(attr, [])?
>
> Really, I'm thinking more along the lines of a dict that only guarantees
> enumeration order (no integer indexed access) in the specific cases
> where people "need" it (ordered kwargs for e.g. the OrderedDict
> constructor would be another example), while being 'lightweight' enough
> (in terms of not having a lot of extra machinery dedicated to
> maintaining the order) to ultimately be used as the real dict
> implementation (and therefore usable for kwargs, class dictionaries,
> etc)


I understand. More like the function of DEFAULT_PREDICATE_ORDERING
here: https://github.com/westurner/healthref/blob/gh-pages/healthref.py#L100
.

That would indeed be useful. What would you call it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141218/8d4fbd36/attachment-0001.html>


More information about the Python-ideas mailing list