Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17085
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: Verbose and flexible args and kwargs syntax |
| Date | 2011-12-12 16:58 -0500 |
| References | <4EE5C576.2000307@gmail.com> <mailman.3550.1323705162.27778.python-list@python.org> <e31c5737-5514-4031-acdd-4882fe11b867@y7g2000vbe.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3571.1323727128.27778.python-list@python.org> (permalink) |
On 12/12/2011 12:12 PM, Eelco wrote: > Im not sure if this is a genuine understanding, or trollish > obtuseness. If you are referring to what I write, it is based on genuine understanding of Python. > Yes, the target can be anywhere in the sequence. And yes, the > resulting list can contain objects of any type, so its very flexible > in that regard too. > > But to relate it to the topic of this thread: no, the syntax does not > allow one to select the type of the resulting sequence. It always > constructs a list. One use case of *target is to ignore the stuff collected in the target because one only wants a few end values from the iterable. Another is to pull stuff out because one wants to iterate through the rest. For both uses, a list is as good as anything. > Yes, we can cast the list to be whatever we want on the next line, Convert. For the very few cases one wants to do this, it is quite adequate. > but the question is whether this language design can be improved upon. Not easily. > The choice of a list feels arbitrary, On the contrary, a list is precisely what is needed to collect an indefinite number of leftovers. > adding another line to cast it to > something else would be even more verbose, and whats more, there would > be serious performance implications if one should seek to apply this > pattern to a deque/linkedlist; it would make taking off the head/tail > of the list from a constant to a linear operation. For a linked list, no *target and no copying is needed: head, tail = llist >>>> head, deque(tail) = somedeque > > Is better in every way I can think of (readability, consistence, > performance) than: >>>> head, *tail = somedeque >>>> tail = deque(tail) But your suggestion is much worse in each way than head = somedeque.popleft() To repeat, there is no reason to copy even once. If one does not want to mutate the deque, then one mutates an iterator view of the deque. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 10:52 -0500
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 09:12 -0800
Re: Verbose and flexible args and kwargs syntax Terry Reedy <tjreedy@udel.edu> - 2011-12-12 16:58 -0500
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-12 15:40 -0800
Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-12 18:41 -0700
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 00:44 -0800
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 01:26 -0800
Re: Verbose and flexible args and kwargs syntax Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-13 11:15 -0700
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 12:32 -0800
Re: Verbose and flexible args and kwargs syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-12-13 01:34 +0000
Re: Verbose and flexible args and kwargs syntax alex23 <wuwei23@gmail.com> - 2011-12-12 16:27 -0800
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 00:30 -0800
Re: Verbose and flexible args and kwargs syntax Cameron Simpson <cs@zip.com.au> - 2011-12-14 06:11 +1100
Re: Verbose and flexible args and kwargs syntax Eelco <hoogendoorn.eelco@gmail.com> - 2011-12-13 12:14 -0800
csiph-web