This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Antony.Lee
Recipients Antony.Lee
Date 2014-12-18.12:56:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1418907389.55.0.608772896554.issue23080@psf.upfronthosting.co.za>
In-reply-to
Content
This patch makes BoundArguments.arguments an unordered dict.  As discussed on python-ideas, the rationale for this is

1. The current ordering in ba.arguments is the one of the parameters in the signature (which is already available via the ba.signature attribute), not the one in which the arguments are given (which will always be unavailable as long as Python doesn't keep the order of keyword arguments), so no information is lost by this patch.

2. The recipe in the docs for updating ba.arguments to also contain default argument values breaks that ordering, making __eq__ behavior difficult to explain:

s = signature(lambda x=None, y=None: None)
ba0 = s.bind()
ba1 = s.bind(x=None)
ba2 = s.bind(y=None)
<add default values as suggested in the docs>

At that point, with the current implementation, we'll have ba0 == ba1 != ba2... why?

3. Implementing ba.arguments as a regular dict makes signature.bind much faster, which is important e.g. if it is used in a decorating type-checker as suggested in PEP362.  (That specific issue could also be improved by a C-implemented OrderedDict, but the other reasons remain valid.)
History
Date User Action Args
2014-12-18 12:56:29Antony.Leesetrecipients: + Antony.Lee
2014-12-18 12:56:29Antony.Leesetmessageid: <1418907389.55.0.608772896554.issue23080@psf.upfronthosting.co.za>
2014-12-18 12:56:29Antony.Leelinkissue23080 messages
2014-12-18 12:56:28Antony.Leecreate