Pop a list from beginning ? and memory saving...

Aahz aahz at pythoncraft.com
Wed Jun 19 15:19:52 EDT 2002


In article <aep4jb$1q8h$1 at news.idiom.com>,
James T. Dennis <jadestar at idiom.com> wrote:
>
> It might be better to have a hack to the implementation of the
> list primitives --- so they defer the shift of remaining elements
> until GC.  The head of the list could point at the first none 
> deleted item.  Then pop(0) could be implemented in O(1) time and
> the garbage collector would eventually come along to do it's 
> job.

While this might be a worthwhile optimization, it has absolutely nothing
to do with GC.  Each time an element were popped off the front, its
object would be decreffed and possibly deleted.  GC runs completely
independently of individual objects.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/



More information about the Python-list mailing list