On 09.01.17 12:46, Paul Rubin wrote:
Serhiy Storchaka <storch...@gmail.com> writes:
gen = (expensive_calculation(x) for x in data)
result = [(tmp, tmp + 1) for tmp in gen]
result = [(tmp, tmp+1) for tmp in map(expensive_calculation, data)]
Yes, of course, but only in the case of one-argument function
expensive_calculation(). If this is just an expensive expression or need
to pass multiple arguments to an expensive function, a generator
expression could look simpler than a lambda or a local function.
--
https://mail.python.org/mailman/listinfo/python-list