[Python-ideas] Question about `list.insert`

Antoine Pitrou solipsis at pitrou.net
Fri Feb 7 23:33:15 CET 2014


On Sat, 08 Feb 2014 06:50:29 +0900
"Stephen J. Turnbull" <stephen at xemacs.org>
wrote:
> 
> Certainly, it would be possible to keep an additional start pointer,
> and advance that for deletions at position 0, then use that space for
> insertions at 0 (or perhaps "early" in the list) if available.

Possible, and quite reasonable actually.

> But
> the OP refers to *allocation*, and specifically disallows "reserving
> space".

Ok, so you're arguing about a misunderstanding by the OP about how
memory allocation works. That doesn't mean that overallocating at the
front is any more difficult than overallocating at the end is (the
latter being of course already implemented by the list datatype).

Regards

Antoine.




More information about the Python-ideas mailing list