I understand that you could be more efficient with memory in the implementation of map than in how you might do it over a loop. However, I see that using a map function over
The difference is due to append, not map. Try this:
res = [] res = [square2(foo) for foo in foobar]