dict.items() vs dict.iteritems and similar questions

Paul Rubin http
Wed Mar 14 22:16:41 CET 2007

Laurent Pointal <laurent.pointal at limsi.fr> writes:
> Both work, you may prefer xrange/iteritems for iteration on large
> collections, you may prefer range/items when processing of the result
> value explicitly need a list (ex. calculate its length) or when you are
> going to manipulate the original container in the loop.

You can use len(d) if d is a dict.

More information about the Python-list mailing list