Hello,

I would like to get advice on the best practice to count elements in a list (built from scractch).
The number of elements is in the range 1e3 and 1e6.

1) I could create a generator and set a counter (i +=1) in the loop.

2) or simply len(mylist).

I don't need the content of the list, indeed, in term of memory I don't
want to wast it. But I suppose len() is optimized too (C impementation).

If you have some thought to share don't hesitate.

Karim
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to