list.__len__() or len(list)

Duncan Booth duncan.booth at invalid.invalid
Wed May 14 11:37:28 EDT 2008


Nikhil <mnikhil at gmail.com> wrote:

> Then why to have __len__() internal method at all when the built-in 
> len() is faster?

Because the internal method is used internally.

The idea is that you define __len__() on your objects when appropriate. You  
are not expected to ever call it.



More information about the Python-list mailing list