Performance problem with filtering
gcordova at hebmex.com
Thu Mar 14 18:08:17 CET 2002
> Anybody wrote a subclassed list yet that is optimized for
> __contains__? Btw.
> this is different from a dictionary, as a list can contain
> the same value twice.
The main hurdle is that the list is a general-purpose list,
and that means that you can't make any assumptions about
To make a fast list --for searches--, either:
1. Keep it sorted, and do a binary search when you need
to find an element.
2. Keep it in a tree, and do a tree search when looking
for an element.
Duplicated elements impact on the performance of this.
More information about the Python-list