On Tue, May 13, 2008 at 5:57 PM, Nikhil <[EMAIL PROTECTED]> wrote:
>  __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.

The purpose of obj.__len__() is to implement len(obj), which simply
calls it.  So obj.__len__() may be faster, but only marginally.  The
reason to prefer len(obj) is that if you inadvertently pass an object
that does not implement __len__, you get the more appropriate
TypeError rather than an AttributeError.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to