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

Tiny optimization in find()

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 2.3
    • Affects Version/s: 2.1.1
    • Component/s: None

      The PyMongo Cursor returns results from a batch by doing self.__data.pop(0) for each element. This requires quadratic time over the size of the batch. In tests, Python can do pop(0) on a 16k-element list in 3 or 4 microseconds, so it's not a big problem. But reversing the list and doing pop() might save a couple microseconds for big queries.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: