mirror of
https://github.com/python/cpython.git
synced 2025-10-17 04:08:28 +00:00
Issue #14373: C implementation of functools.lru_cache() now can be used with
methods.
This commit is contained in:
parent
77cb197aaa
commit
e7070f09bc
3 changed files with 45 additions and 1 deletions
|
@ -1003,6 +1003,16 @@ lru_cache_call(lru_cache_object *self, PyObject *args, PyObject *kwds)
|
|||
return self->wrapper(self, args, kwds);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
lru_cache_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
||||
{
|
||||
if (obj == Py_None || obj == NULL) {
|
||||
Py_INCREF(self);
|
||||
return self;
|
||||
}
|
||||
return PyMethod_New(self, obj);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
lru_cache_cache_info(lru_cache_object *self, PyObject *unused)
|
||||
{
|
||||
|
@ -1115,7 +1125,7 @@ static PyTypeObject lru_cache_type = {
|
|||
lru_cache_getsetlist, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
lru_cache_descr_get, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
offsetof(lru_cache_object, dict), /* tp_dictoffset */
|
||||
0, /* tp_init */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue