I have an iterator result
in one function and I need to return an iterator after making some changes to the objects in result
from that function. I don't want to iterate over the result
as it is causing performance degradation. I want to perform that operation on the fly for each item in the result
.
This is the code which iterates over the result to do that operation.
sols = []
# Get rid of this loop
for sol in result:
sols.append(dict((symbols[abs(lit) - 1], lit > 0) for lit in sol))
# Return iterator object
return (sol for sol in sols)