Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2766

Improve documentation on cursor slices

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.12, 4.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Improve this documentation to more fully explain the implementation and pitfalls:


      Each slice requires a new query with a specific skip and limit. The cursor is cloned internally so as not to change the state of the top level Cursor object. The cursor does not keep an internal list with the entire result set, which would be an inefficient use of memory and may not even be possible depending on the size of the result set.

      Warn (using the ..warning directive in Sphinx) users away from inefficient uses of this feature (though users may stumble upon this feature by accident). For example, warn users away from iteration patterns like:

      cursor = db.coll.find()
      for idx in range(10):

      Each step through the loop above is a new query.

            bernie@mongodb.com Bernie Hackett
            bernie@mongodb.com Bernie Hackett
            0 Vote for this issue
            2 Start watching this issue