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

Optimize PyObject_CallMethod calls

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.5
    • Affects Version/s: None
    • Component/s: None
    • None

      The docs for PyObject_CallMethod say:

      Note that if you only pass PyObject* args, PyObject_CallMethodObjArgs() is a faster alternative.

      We use PyObject_CallMethod in a few places:

      $ git grep PyObject_CallMethod
      bson/_cbsonmodule.c:1070:            PyObject* as_doc = PyObject_CallMethod(value, "as_doc", NULL);
      bson/_cbsonmodule.c:1226:        PyObject* utcoffset = PyObject_CallMethod(value, "utcoffset", NULL);
      bson/_cbsonmodule.c:1285:        binary_value = PyObject_CallMethod(binary_type, "from_uuid", "(Oi)", value, options->uuid_rep);
      bson/_cbsonmodule.c:1983:                    value = PyObject_CallMethod(binary_value, "as_uuid", "(i)", uuid_rep);
      bson/_cbsonmodule.c:2468:                value = PyObject_CallMethod(dec128,
      

      Even thought they pass non-PyObject* args, we may be able to optimize the from_uuid/as_uuid calls too.

        1. screenshot-1.png
          202 kB
          Iris Ho

            Assignee:
            iris.ho@mongodb.com Iris Ho
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: