Tuple parameter unpacking in 3.x

Brett C. bcannon at gmail.com
Tue Oct 7 15:59:20 EDT 2008


On Oct 5, 9:13 am, Terry Reedy <tjre... at udel.edu> wrote:
> Martin Geisler wrote:
> > Steven D'Aprano <st... at REMOVE-THIS-cybersource.com.au> writes:
> >>> From reading the PEP-3113 I got the impression that the author
> >>> thought that this feature was unused and didn't matter.
>
> And that there were good alternatives, and that there were technical
> reasons why maintaining the feature in the face of other arguments
> options would be a nuisance.
>

As the author of PEP 3113, I should probably say something (kudos to
Python-URL bringing this thread to my attention).

There are two things to realize about the tuple unpacking that acted
as motivation. One is supporting them in the compiler is a pain.
Granted that is a weak argument that only the core developers like
myself care about.

Second, tuple unpacking in parameters breaks introspection horribly.
All one has to do is look at the hoops 'inspect' has to jump through
in order to figure out what the heck is going on to see how messy this
is. And I realize some people will say, "but if 'inspect' can handle
it, then who cares about the complexity", but that doesn't work if
'inspect' is viewed purely as a simple wrapper so you don't have to
remember some attribute names and not having to actually perform some
major hoops. I personally prefer being able to introspect from the
interpreter prompt without having to reverse-engineer how the heck
code objects deal with tuple unpacking.

>  >>> With this I wish to say that it matters to me.
>

Well, every feature matters to someone. Question is whether it matters
to enough people to warrant having a feature. I brought this up at
PyCon 2006 through a partially botched lightning talk and on python-
dev through the PEP, so this was not some snap decision on my part
that I rammed through python-dev; there was some arguing for keeping
it from some python-dev members, but Guido agreed with me in the end.

If you still hate me you can find me at PyCon 2009 and tar & feather
me *after* my talk. =)

> >> Alas, I think it's too late. I feel your pain.
>
> > Thanks! And I know it's too late, I should have found out about this
> > earlier :-(
>
> For future reference, the time to have said something would have been
> during the 3 month alpha phase, which is for testing feature and api
> changes.  I suspect, from reading the pydev discussion, that the answer
> still would have been to either use a def statement and add the unpack
> line or to subscript the tuple arg to stick with lambda expressions.
> But who knows?

I have not read this whole thread thoroughly, but it sounds like using
iterator unpacking at the call site (e.g., ``fxn(*args)`` when calling
your lambda) is out of the question because it is from a callback?

As Terry said, the alpha is one way you can give feedback if you don't
want to follow python-dev or python-3000 but still have your opinion
be heard. The other way is to subscribe to the PEP news feed (found
off of http://www.python.org/dev/peps/) to keep on top of PEPs as
practically all language changes have to result in a PEP at some
point.  And of course the last option is to follow python-dev. =)

-Brett



More information about the Python-list mailing list