list.__len__() or len(list)

alex.gaynor at gmail.com alex.gaynor at gmail.com
Tue May 13 20:06:57 EDT 2008


On May 13, 6:57 pm, Nikhil <mnik... at gmail.com> wrote:
> which one is better? and why?
>
> __len__() is a built-in function of the list object and is updated along
> with the list object elements and will be useful incase the list is very
> huge.
>
> len() is an external method again, which may require the processing
> cycles again.
>
> Is it right?

len() is the correct way to do it, methods that begin with __ are
meant to be more internal.



More information about the Python-list mailing list