[Python-Dev] pep 362 - 5th edition (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Wed Jun 20 06:39:41 CEST 2012


On Wed, Jun 20, 2012 at 1:28 PM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:

On 2012-06-19, at 11:24 PM, Nick Coghlan wrote:

The constructor accepts an iterable of Parameter objects rather than a mapping. That's the code I've ended up with:  sig = signature(obj.func)  return Signature(OrderedDict(tuple(sig.parameters.items())[1:]), **sig.optional)

Why require a mapping as the argument? A simple iterable of Parameter objects seems like a more convenient constructor API to me. The constructor can take care of building the mapping from that internally via:

param_map = OrderedDict((param.name, param for param in parameters))

Still looks better than creating implicit & explicit copies ;)

Indeed :)

As for slices support in OrderedDict -- it would return values, so it won't solve the problem anyways.

You wouldn't want to do it anyway - while slices happen to not be hashable now, there's no strong reason behind that.

Cheers, Nick.

-- Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-Dev mailing list