_functoolsmodule.c.h 3.1 KB

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