In python, what does len(list) do?

Posted by nsharish on Stack Overflow See other posts from Stack Overflow or by nsharish
Published on 2010-03-08T07:18:36Z Indexed on 2010/03/08 7:21 UTC
Read the original article Hit count: 184

Filed under:
|

My doubt is that if the len(list) calculates the length of the list everytime it is called or it returns the value of the builtin counter.
I have a context where i need to check the length of list everytime in a loop, like

listData = []
for value in ioread():
    if len(listData)>=25:
        processlistdata()
        clearlistdata()
    listData.append(value)
Should I check len(listData) every iteration, or can I have a counter for the length of the list.

© Stack Overflow or respective owner

Related posts about python

Related posts about lists