[Python-ideas] pop multiple elements of a list at once

Nick Coghlan ncoghlan at gmail.com
Sun Jul 11 23:18:49 CEST 2010

I think you overestimate how standardised we could make this across
all platforms and data structures. Under the hood, any such expansion
to the .pop API would almost certainly be defined as equivalent to:

def pop(self, index):
  result = self[index]
  del self[index]
  return result

such that slice objects could be passed in as well as integers (or
integer equivalents). (Currently pop on builtin objects rejects slice
objects, as it only works with integers)

In the meantime, if you want to manipulate memory while minimising
copying, then the 2.7 memoryview object may be for you (assuming you
can switch to the later version).


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

More information about the Python-ideas mailing list