Search code examples
pythonperformancepymongodatabase-cursor

How to efficiently use PyMongo cursor


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


Solution

  • 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.