Issue #25447: The lru_cache() wrapper objects now can be copied and pickled
(by returning the original object unchanged).
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 1f98067..fadc0a9 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1047,6 +1047,12 @@
Py_RETURN_NONE;
}
+static PyObject *
+lru_cache_reduce(PyObject *self, PyObject *unused)
+{
+ return PyObject_GetAttrString(self, "__qualname__");
+}
+
static int
lru_cache_tp_traverse(lru_cache_object *self, visitproc visit, void *arg)
{
@@ -1097,6 +1103,7 @@
static PyMethodDef lru_cache_methods[] = {
{"cache_info", (PyCFunction)lru_cache_cache_info, METH_NOARGS},
{"cache_clear", (PyCFunction)lru_cache_cache_clear, METH_NOARGS},
+ {"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS},
{NULL}
};