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

Wes Turner wes.turner at gmail.com
Thu Dec 18 17:18:59 CET 2014


> 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, [])?

On Thu, Dec 18, 2014 at 10:09 AM, <random832 at fastmail.us> wrote:
>
> On Thu, Dec 18, 2014, at 02:05, Nick Coghlan wrote:
> > As far as I'm aware, it's an ordered dictionary because that makes the
> > default repr() predictable when binding arguments for a given function
> > (in the absence of after-the-fact manipulation like the example in the
> > docs that injects the default values as explicitly bound arguments).
> >
> > The inspect.signature() machinery includes quite a few things like
> > that where the serialisation as a human readable string is considered
> > as important then the programmatic representation.
>
> 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?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141218/ba7b337f/attachment.html>


More information about the Python-ideas mailing list