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

Nick Coghlan ncoghlan at gmail.com
Mon Jul 12 17:41:48 CEST 2010

On Tue, Jul 13, 2010 at 1:13 AM, Diego Jacobi <jacobidiego at gmail.com> wrote:
> Hi.
> I apologize if i am having difficulties to explain myself in English.
> Also i just realise that i wasnt answering to the list, but directly
> to Brett Cannon. Sorry for that.
> Also i am taking into account that you are right and my concept of how
> memory is handled here for lists is way too different as how i am more
> used to work in firmwares.
> Anyway, the concept of my idea comes of my understanding of an
> low-leveled array.

For builtin lists and most other Python container types, think more
along the lines of a list of pointers rather than a list of numbers.
However, for the behaviour of array.array (rather than the builtin
list), your understanding of the cost of slicing was actually pretty
close to correct (since storing actual values rather than pointers is
the way array.array gains its comparative memory efficiency).

Python doesn't actually excel at memory efficiency when manipulating
large data sets using conventional syntax (e.g. slicing). The old
buffer objects were an initial attempt at providing memory efficient
access to segments of data buffers, while the recently added
memoryview objects are a more sophisticated (and safer) approach to
the same idea. The NumPy extension, on the other hand, is able to very
efficiently provide multiple views of the same region of memory
without requiring copying (NumPy itself isn't particularly small


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

More information about the Python-ideas mailing list