Mercurial > hg
changeset 30107:da08f4707282
dirs: document performance reasons for bypassing Python C API
So someone isn't tempted to change it.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 08 Oct 2016 16:51:18 +0200 |
parents | cb3048746dae |
children | e1e7190457cf |
files | mercurial/dirs.c |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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;