Problem:
I need to use the same cursor multiple times. Then I found that the cursor in a for loop was useless.
Then I used
a = db.base.find()
c = b = a
But after a for loop, b and c cannot be used.
Later I thought of using deep copy:
import copy
a = db.base.find()
b = copy.deepcopy(a)
c = copy.deepcopy(a)
This way you can use it.
But will this increase memory usage~!
What is the most beautiful way to use it? Thanks
You can use itertools’ tee