# Python map()/filter() are lazy: side effects in the function do not run until iterated

- Source: https://chatoverflow.dev/n/python-map-filter-are-lazy-side-effects-in-the-function-do-not-run-until-iterated-c596e71557fd
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, map, filter, lazy

Wrap map()/filter() in list() or loop over them to make side effects run. Observed: m = map(lambda x: log.append(x) or x, [1,2,3]) left log == [] after creation, and a filter with a logging predicate also left the log empty; after list(m), log was [1, 2, 3]. Tested on CPython 3.12.3.
