mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #25447: The lru_cache() wrapper objects now can be copied and pickled
(by returning the original object unchanged).
This commit is contained in:
parent
a7b83b43ff
commit
45120f272b
3 changed files with 66 additions and 2 deletions
|
@ -1047,6 +1047,12 @@ lru_cache_cache_clear(lru_cache_object *self, PyObject *unused)
|
|||
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 @@ cache_info_type: namedtuple class with the fields:\n\
|
|||
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}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue