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