A very interesting question which has an interesting answer.
The map function returns a Map object which is iterable. map is performing its calculation lazily so the function wouldn’t get called unless you iterate that object.
So if you do:
x = map(D.attach_item, items)
for i in x:
continue
The expected result will show up.