Index: Doc/lib/libfuncs.tex =================================================================== --- Doc/lib/libfuncs.tex (revision 50627) +++ Doc/lib/libfuncs.tex (working copy) @@ -477,6 +477,24 @@ \code{[item for item in \var{list} if function(item)]} if function is not \code{None} and \code{[item for item in \var{list} if item]} if function is \code{None}. + + When dealing with instances of subclasses of \class{str}, \class{unicode} + or \class{tuple}, \function{filter()} utilises a number of shortcuts for + performance reasons: + + \begin{itemize} + \item \function{filter()} will not invoke any overridden + \method{__len__()} methods; that is, it will explicitly invoke + e.g. \code{str.__len__()}. + \item \function{filter} will not utilise any implementation of the + iterator protocol defined by the subclass. + \end{itemize} + + Further note that in spite of these points, \function{filter()} \emph{will} + call the subclass's \method{__getitem__()} method. To sum up, when + fetching the object's elements, \function{filter()} will use a + combination of the subclass's \method{__getitem()__} and the parent + class's \method{__len__()}. \end{funcdesc} \begin{funcdesc}{float}{\optional{x}}