Branch data Line data Source code
1 : : /*[clinic input]
2 : : preserve
3 : : [clinic start generated code]*/
4 : :
5 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 : : # include "pycore_gc.h" // PyGC_Head
7 : : # include "pycore_runtime.h" // _Py_ID()
8 : : #endif
9 : :
10 : :
11 : : PyDoc_STRVAR(_functools_cmp_to_key__doc__,
12 : : "cmp_to_key($module, /, mycmp)\n"
13 : : "--\n"
14 : : "\n"
15 : : "Convert a cmp= function into a key= function.\n"
16 : : "\n"
17 : : " mycmp\n"
18 : : " Function that compares two objects.");
19 : :
20 : : #define _FUNCTOOLS_CMP_TO_KEY_METHODDEF \
21 : : {"cmp_to_key", _PyCFunction_CAST(_functools_cmp_to_key), METH_FASTCALL|METH_KEYWORDS, _functools_cmp_to_key__doc__},
22 : :
23 : : static PyObject *
24 : : _functools_cmp_to_key_impl(PyObject *module, PyObject *mycmp);
25 : :
26 : : static PyObject *
27 : 2 : _functools_cmp_to_key(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
28 : : {
29 : 2 : PyObject *return_value = NULL;
30 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
31 : :
32 : : #define NUM_KEYWORDS 1
33 : : static struct {
34 : : PyGC_Head _this_is_not_used;
35 : : PyObject_VAR_HEAD
36 : : PyObject *ob_item[NUM_KEYWORDS];
37 : : } _kwtuple = {
38 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
39 : : .ob_item = { &_Py_ID(mycmp), },
40 : : };
41 : : #undef NUM_KEYWORDS
42 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
43 : :
44 : : #else // !Py_BUILD_CORE
45 : : # define KWTUPLE NULL
46 : : #endif // !Py_BUILD_CORE
47 : :
48 : : static const char * const _keywords[] = {"mycmp", NULL};
49 : : static _PyArg_Parser _parser = {
50 : : .keywords = _keywords,
51 : : .fname = "cmp_to_key",
52 : : .kwtuple = KWTUPLE,
53 : : };
54 : : #undef KWTUPLE
55 : : PyObject *argsbuf[1];
56 : : PyObject *mycmp;
57 : :
58 [ + - + - : 2 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
+ - - + ]
59 [ - + ]: 2 : if (!args) {
60 : 0 : goto exit;
61 : : }
62 : 2 : mycmp = args[0];
63 : 2 : return_value = _functools_cmp_to_key_impl(module, mycmp);
64 : :
65 : 2 : exit:
66 : 2 : return return_value;
67 : : }
68 : :
69 : : PyDoc_STRVAR(_functools__lru_cache_wrapper_cache_info__doc__,
70 : : "cache_info($self, /)\n"
71 : : "--\n"
72 : : "\n"
73 : : "Report cache statistics");
74 : :
75 : : #define _FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_INFO_METHODDEF \
76 : : {"cache_info", (PyCFunction)_functools__lru_cache_wrapper_cache_info, METH_NOARGS, _functools__lru_cache_wrapper_cache_info__doc__},
77 : :
78 : : static PyObject *
79 : : _functools__lru_cache_wrapper_cache_info_impl(PyObject *self);
80 : :
81 : : static PyObject *
82 : 0 : _functools__lru_cache_wrapper_cache_info(PyObject *self, PyObject *Py_UNUSED(ignored))
83 : : {
84 : 0 : return _functools__lru_cache_wrapper_cache_info_impl(self);
85 : : }
86 : :
87 : : PyDoc_STRVAR(_functools__lru_cache_wrapper_cache_clear__doc__,
88 : : "cache_clear($self, /)\n"
89 : : "--\n"
90 : : "\n"
91 : : "Clear the cache and cache statistics");
92 : :
93 : : #define _FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_CLEAR_METHODDEF \
94 : : {"cache_clear", (PyCFunction)_functools__lru_cache_wrapper_cache_clear, METH_NOARGS, _functools__lru_cache_wrapper_cache_clear__doc__},
95 : :
96 : : static PyObject *
97 : : _functools__lru_cache_wrapper_cache_clear_impl(PyObject *self);
98 : :
99 : : static PyObject *
100 : 1 : _functools__lru_cache_wrapper_cache_clear(PyObject *self, PyObject *Py_UNUSED(ignored))
101 : : {
102 : 1 : return _functools__lru_cache_wrapper_cache_clear_impl(self);
103 : : }
104 : : /*[clinic end generated code: output=7e7f3bcf9ed61f23 input=a9049054013a1b77]*/
|