diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Modules/_bisectmodule.c | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/_bisectmodule.c')
-rw-r--r-- | contrib/tools/python3/src/Modules/_bisectmodule.c | 220 |
1 files changed, 110 insertions, 110 deletions
diff --git a/contrib/tools/python3/src/Modules/_bisectmodule.c b/contrib/tools/python3/src/Modules/_bisectmodule.c index 82d800d9a8..c0f9d7e9f2 100644 --- a/contrib/tools/python3/src/Modules/_bisectmodule.c +++ b/contrib/tools/python3/src/Modules/_bisectmodule.c @@ -6,16 +6,16 @@ Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru). #define PY_SSIZE_T_CLEAN #include "Python.h" -/*[clinic input] -module _bisect -[clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4d56a2b2033b462b]*/ - -#include "clinic/_bisectmodule.c.h" - +/*[clinic input] +module _bisect +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=4d56a2b2033b462b]*/ + +#include "clinic/_bisectmodule.c.h" + _Py_IDENTIFIER(insert); -static inline Py_ssize_t +static inline Py_ssize_t internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi) { PyObject *litem; @@ -51,63 +51,63 @@ internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t return lo; } -/*[clinic input] -_bisect.bisect_right -> Py_ssize_t - - a: object - x: object - lo: Py_ssize_t = 0 - hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None - -Return the index where to insert item x in list a, assuming a is sorted. - -The return value i is such that all e in a[:i] have e <= x, and all e in -a[i:] have e > x. So if x already appears in the list, i points just -beyond the rightmost x already there - -Optional args lo (default 0) and hi (default len(a)) bound the -slice of a to be searched. -[clinic start generated code]*/ - -static Py_ssize_t -_bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi) -/*[clinic end generated code: output=419e150cf1d2a235 input=e72212b282c83375]*/ +/*[clinic input] +_bisect.bisect_right -> Py_ssize_t + + a: object + x: object + lo: Py_ssize_t = 0 + hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None + +Return the index where to insert item x in list a, assuming a is sorted. + +The return value i is such that all e in a[:i] have e <= x, and all e in +a[i:] have e > x. So if x already appears in the list, i points just +beyond the rightmost x already there + +Optional args lo (default 0) and hi (default len(a)) bound the +slice of a to be searched. +[clinic start generated code]*/ + +static Py_ssize_t +_bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi) +/*[clinic end generated code: output=419e150cf1d2a235 input=e72212b282c83375]*/ { - return internal_bisect_right(a, x, lo, hi); + return internal_bisect_right(a, x, lo, hi); } -/*[clinic input] -_bisect.insort_right - - a: object - x: object - lo: Py_ssize_t = 0 - hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None - -Insert item x in list a, and keep it sorted assuming a is sorted. - -If x is already in a, insert it to the right of the rightmost x. - -Optional args lo (default 0) and hi (default len(a)) bound the -slice of a to be searched. -[clinic start generated code]*/ - +/*[clinic input] +_bisect.insort_right + + a: object + x: object + lo: Py_ssize_t = 0 + hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None + +Insert item x in list a, and keep it sorted assuming a is sorted. + +If x is already in a, insert it to the right of the rightmost x. + +Optional args lo (default 0) and hi (default len(a)) bound the +slice of a to be searched. +[clinic start generated code]*/ + static PyObject * -_bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi) -/*[clinic end generated code: output=c2caa3d4cd02035a input=d1c45bfa68182669]*/ +_bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi) +/*[clinic end generated code: output=c2caa3d4cd02035a input=d1c45bfa68182669]*/ { - PyObject *result; - Py_ssize_t index = internal_bisect_right(a, x, lo, hi); + PyObject *result; + Py_ssize_t index = internal_bisect_right(a, x, lo, hi); if (index < 0) return NULL; - if (PyList_CheckExact(a)) { - if (PyList_Insert(a, index, x) < 0) + if (PyList_CheckExact(a)) { + if (PyList_Insert(a, index, x) < 0) return NULL; - } - else { - result = _PyObject_CallMethodId(a, &PyId_insert, "nO", index, x); + } + else { + result = _PyObject_CallMethodId(a, &PyId_insert, "nO", index, x); if (result == NULL) return NULL; Py_DECREF(result); @@ -116,7 +116,7 @@ _bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x, Py_RETURN_NONE; } -static inline Py_ssize_t +static inline Py_ssize_t internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t hi) { PyObject *litem; @@ -152,64 +152,64 @@ internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t h return lo; } - -/*[clinic input] -_bisect.bisect_left -> Py_ssize_t - - a: object - x: object - lo: Py_ssize_t = 0 - hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None - -Return the index where to insert item x in list a, assuming a is sorted. - -The return value i is such that all e in a[:i] have e < x, and all e in -a[i:] have e >= x. So if x already appears in the list, i points just -before the leftmost x already there. - -Optional args lo (default 0) and hi (default len(a)) bound the -slice of a to be searched. -[clinic start generated code]*/ - -static Py_ssize_t -_bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi) -/*[clinic end generated code: output=af82168bc2856f24 input=2bd90f34afe5609f]*/ + +/*[clinic input] +_bisect.bisect_left -> Py_ssize_t + + a: object + x: object + lo: Py_ssize_t = 0 + hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None + +Return the index where to insert item x in list a, assuming a is sorted. + +The return value i is such that all e in a[:i] have e < x, and all e in +a[i:] have e >= x. So if x already appears in the list, i points just +before the leftmost x already there. + +Optional args lo (default 0) and hi (default len(a)) bound the +slice of a to be searched. +[clinic start generated code]*/ + +static Py_ssize_t +_bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi) +/*[clinic end generated code: output=af82168bc2856f24 input=2bd90f34afe5609f]*/ { - return internal_bisect_left(a, x, lo, hi); + return internal_bisect_left(a, x, lo, hi); } -/*[clinic input] -_bisect.insort_left - - a: object - x: object - lo: Py_ssize_t = 0 - hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None - -Insert item x in list a, and keep it sorted assuming a is sorted. - -If x is already in a, insert it to the left of the leftmost x. - -Optional args lo (default 0) and hi (default len(a)) bound the -slice of a to be searched. -[clinic start generated code]*/ - +/*[clinic input] +_bisect.insort_left + + a: object + x: object + lo: Py_ssize_t = 0 + hi: Py_ssize_t(c_default='-1', accept={int, NoneType}) = None + +Insert item x in list a, and keep it sorted assuming a is sorted. + +If x is already in a, insert it to the left of the leftmost x. + +Optional args lo (default 0) and hi (default len(a)) bound the +slice of a to be searched. +[clinic start generated code]*/ + static PyObject * -_bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x, - Py_ssize_t lo, Py_ssize_t hi) -/*[clinic end generated code: output=9e8356c0844a182b input=bc4583308bce00cc]*/ +_bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x, + Py_ssize_t lo, Py_ssize_t hi) +/*[clinic end generated code: output=9e8356c0844a182b input=bc4583308bce00cc]*/ { - PyObject *result; - Py_ssize_t index = internal_bisect_left(a, x, lo, hi); + PyObject *result; + Py_ssize_t index = internal_bisect_left(a, x, lo, hi); if (index < 0) return NULL; - if (PyList_CheckExact(a)) { - if (PyList_Insert(a, index, x) < 0) + if (PyList_CheckExact(a)) { + if (PyList_Insert(a, index, x) < 0) return NULL; } else { - result = _PyObject_CallMethodId(a, &PyId_insert, "nO", index, x); + result = _PyObject_CallMethodId(a, &PyId_insert, "nO", index, x); if (result == NULL) return NULL; Py_DECREF(result); @@ -219,10 +219,10 @@ _bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x, } static PyMethodDef bisect_methods[] = { - _BISECT_BISECT_RIGHT_METHODDEF - _BISECT_INSORT_RIGHT_METHODDEF - _BISECT_BISECT_LEFT_METHODDEF - _BISECT_INSORT_LEFT_METHODDEF + _BISECT_BISECT_RIGHT_METHODDEF + _BISECT_INSORT_RIGHT_METHODDEF + _BISECT_BISECT_LEFT_METHODDEF + _BISECT_INSORT_LEFT_METHODDEF {NULL, NULL} /* sentinel */ }; |