Find an Item in a Sorted List

Jeff Shannon jeff at
Wed Feb 27 19:47:43 EST 2002

"Christopher A. Craig" wrote:

> hankc at (HankC) writes:
> > - does the del(datalines) call free the memory (not necessarily
> > immediately) for the list resource?
> It frees it immediately.

Note, however, that this applies only to your list item itself, not to the
contained items.  Those contained items are *also* referenced by the
dictionary -- you haven't copied the strings, you've created two different
references to them.  Deleting the list will eliminate one of those sets of
references; however, it's not *that* big of a deal, since references don't
take much space, relative to strings.  For the most part, only worry about
freeing references if you start to notice memory consumption being a
problem.  (Since you've got 10,000 items, then it might be justified, but
under most circumstances, it works just fine to leave things alone until
they go out of scope.  Using del is not often necessary.)

Jeff Shannon
Credit International

More information about the Python-list mailing list