[issue9218] pop multiple elements of a list at once
Mark Dickinson
report at bugs.python.org
Sat Jul 10 21:51:23 CEST 2010
Mark Dickinson <dickinsm at gmail.com> added the comment:
The python-ideas mailing list might be a better place to discuss this. Note that it's too late for new features in the 2.x series, so I'm changing the version to 3.2
> pop self.recv_buffer[:size]
I don't think this'll fly, even if you spell it pop(self.recv_buffer[:size]). It's not worth a new built-in function, let alone a grammar change.
> self.recv_buffer.pop(,-size)
Something like this seems more reasonable, especially if it can be done without introducing new syntax and in a fully backwards-compatible way.
One idea that seems fairly natural to me would be to allow list.pop and friends to support slices, so you could do:
last2 = slice(None, -2)
self.recv_buffer.pop(last2)
or even
penultimate, ultimate = self.recv_buffer.pop(last2)
It would require some work to implement and debug this, though.
----------
components: +Interpreter Core
nosy: +mark.dickinson
type: performance -> feature request
versions: +Python 3.2 -Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9218>
_______________________________________
More information about the Python-bugs-list
mailing list