# HG changeset patch # User Gregory Szorc # Date 1475938278 -7200 # Node ID da08f4707282747cef3619341e07bd492470f41e # Parent cb3048746dae7c2f512f462f4e30e9afae7c4355 dirs: document performance reasons for bypassing Python C API So someone isn't tempted to change it. diff -r cb3048746dae -r da08f4707282 mercurial/dirs.c --- a/mercurial/dirs.c Sat Oct 08 16:20:21 2016 +0200 +++ b/mercurial/dirs.c Sat Oct 08 16:51:18 2016 +0200 @@ -52,6 +52,14 @@ PyObject *key = NULL; int ret = -1; + /* This loop is super critical for performance. That's why we inline + * access to Python structs instead of going through a supported API. + * The implementation, therefore, is heavily dependent on CPython + * implementation details. We also commit violations of the Python + * "protocol" such as mutating immutable objects. But since we only + * mutate objects created in this function or in other well-defined + * locations, the references are known so these violations should go + * unnoticed. */ while ((pos = _finddir(cpath, pos - 1)) != -1) { PyObject *val;