removeall() in list

Paul Rubin http
Sat Jan 12 19:26:04 CET 2008

castironpi at writes:
> 2) List is referenced by others; concurrent modifications may be going
> on; can not replace it.  Can I make asynchronous modifications and
> merge the changes, SCM-style?

Nothing else should have direct access to the list.

> 3) Dictionary returns non-static order; order is important.  Create a
> int-func tuple and sort dictionary results?  Perhaps.  That's sounding
> pretty good.

If the list is not too long, that is reasonable.  If it -is- long, the
remove operations can be slow, but that's ok if there's not too many.
If the list is long -and- there's a lot of adds/removes, maybe you
want something like an AVL tree.

More information about the Python-list mailing list