Performance problem with filtering
Gustavo Cordova
gcordova at hebmex.com
Thu Mar 14 12:08:17 EST 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.
>
> Gerhard
> --
The main hurdle is that the list is a general-purpose list,
and that means that you can't make any assumptions about
the data.
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.
-gustavo
More information about the Python-list
mailing list