MCPcopy Create free account
hub / github.com/catboost/catboost / KeyByIndex

Function KeyByIndex

library/python/runtime_py3/__res.cpp:42–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42PyObject* KeyByIndex(PyObject* self[[maybe_unused]], PyObject *const *args, Py_ssize_t nargs) noexcept {
43 if (nargs != 1) {
44 PyErr_Format(PyExc_TypeError, "__res.key_by_index takes 1 positional arguments but %z were given", nargs);
45 return nullptr;
46 }
47 if (PyFloat_Check(args[0])) {
48 PyErr_SetString(PyExc_TypeError, "integer argument expected, got float");
49 return nullptr;
50 }
51 PyObject* asNum = PyNumber_Index(args[0]);
52 if (!asNum) {
53 return nullptr;
54 }
55 const auto idx = PyLong_AsSize_t(asNum);
56 Py_DECREF(asNum);
57 if (idx == static_cast<size_t>(-1)) {
58 return nullptr;
59 }
60 return CallWithErrorTranslation([&]{
61 const auto res = NResource::KeyByIndex(idx);
62 return PyBytes_FromStringAndSize(res.data(), res.size());
63 });
64}
65
66PyObject* Find(PyObject* self[[maybe_unused]], PyObject *const* args, Py_ssize_t nargs) noexcept {
67 if (nargs != 1) {

Callers 2

ListAllKeysMethod · 0.85
FilterByPrefixMethod · 0.85

Calls 3

CallWithErrorTranslationFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected