diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-09-06 08:52:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-06 08:52:53 (GMT) |
commit | 65a2bce70421197605feeed3351a4577462aae06 (patch) | |
tree | 8ce450736373c8686cba1537fc8495820be69639 /Modules | |
parent | 6f8411cfd68134ccae01b0b4cb332578008a69e3 (diff) | |
download | cpython-65a2bce70421197605feeed3351a4577462aae06.zip cpython-65a2bce70421197605feeed3351a4577462aae06.tar.gz cpython-65a2bce70421197605feeed3351a4577462aae06.tar.bz2 |
gh-108717: Speedup `os.DirEntry.is_junction` function (#108718)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/clinic/posixmodule.c.h | 14 | ||||
-rw-r--r-- | Modules/posixmodule.c | 6 |
2 files changed, 7 insertions, 13 deletions
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h index 854fd6c..c3e7f86 100644 --- a/Modules/clinic/posixmodule.c.h +++ b/Modules/clinic/posixmodule.c.h @@ -10695,22 +10695,18 @@ PyDoc_STRVAR(os_DirEntry_is_junction__doc__, "Return True if the entry is a junction; cached per entry."); #define OS_DIRENTRY_IS_JUNCTION_METHODDEF \ - {"is_junction", _PyCFunction_CAST(os_DirEntry_is_junction), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_junction__doc__}, + {"is_junction", (PyCFunction)os_DirEntry_is_junction, METH_NOARGS, os_DirEntry_is_junction__doc__}, static int -os_DirEntry_is_junction_impl(DirEntry *self, PyTypeObject *defining_class); +os_DirEntry_is_junction_impl(DirEntry *self); static PyObject * -os_DirEntry_is_junction(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) +os_DirEntry_is_junction(DirEntry *self, PyObject *Py_UNUSED(ignored)) { PyObject *return_value = NULL; int _return_value; - if (nargs) { - PyErr_SetString(PyExc_TypeError, "is_junction() takes no arguments"); - goto exit; - } - _return_value = os_DirEntry_is_junction_impl(self, defining_class); + _return_value = os_DirEntry_is_junction_impl(self); if ((_return_value == -1) && PyErr_Occurred()) { goto exit; } @@ -11992,4 +11988,4 @@ exit: #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ -/*[clinic end generated code: output=30c63cb556431cea input=a9049054013a1b77]*/ +/*[clinic end generated code: output=1dd5aa7495cd6e3a input=a9049054013a1b77]*/ diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index b4c502b..c434039 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -14576,15 +14576,13 @@ os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class) /*[clinic input] os.DirEntry.is_junction -> bool - defining_class: defining_class - / Return True if the entry is a junction; cached per entry. [clinic start generated code]*/ static int -os_DirEntry_is_junction_impl(DirEntry *self, PyTypeObject *defining_class) -/*[clinic end generated code: output=7061a07b0ef2cd1f input=475cd36fb7d4723f]*/ +os_DirEntry_is_junction_impl(DirEntry *self) +/*[clinic end generated code: output=97f64d5d99eeccb5 input=4fc8e701eea118a1]*/ { #ifdef MS_WINDOWS return self->win32_lstat.st_reparse_tag == IO_REPARSE_TAG_MOUNT_POINT; |