quantifiedcode / python-anti-patterns

An open collection of Python anti-patterns and worst practices.
https://quantifiedcode.github.io/python-anti-patterns
Other
1.71k stars 249 forks source link

Update iteration example #57

Closed srus closed 9 years ago

srus commented 9 years ago

Use iteritems() instead of items() to iterate over a list. Better memory footprint since it uses an Iterator object instead of creating a new list. This is the default behaviour for items() in Python 3.x.

See https://docs.python.org/2/library/stdtypes.html#dict.iteritems

programmdesign commented 9 years ago

@srus: Thanks