How to efficiently use PyMongo cursor
Question:
Please propose ways to access data returned from collections.find()
in an efficient manner.
Is a for
iteration the recommended way?
How do I keep the character of a cursor being an Iterable
?
Thx
Answers:
Briefly:
A cursor implements methods of Iterable
and Iterator
(after diving into the code of PyMongo’s cursor.py
). Thus, all the usual care working with iterators has to be taken.
Please propose ways to access data returned from collections.find()
in an efficient manner.
Is a for
iteration the recommended way?
How do I keep the character of a cursor being an Iterable
?
Thx
Briefly:
A cursor implements methods of Iterable
and Iterator
(after diving into the code of PyMongo’s cursor.py
). Thus, all the usual care working with iterators has to be taken.