@@ -332,6 +332,28 @@ get_key(Node *node)
332332 return node -> key ;
333333}
334334
335+ static PyObject *
336+ LRU_update (LRU * self , PyObject * args , PyObject * kwargs )
337+ {
338+ PyObject * key , * value ;
339+ PyObject * arg = NULL ;
340+ Py_ssize_t pos = 0 ;
341+
342+ if ((PyArg_ParseTuple (args , "|O" , & arg ))) {
343+ if (arg && PyDict_Check (arg )) {
344+ while (PyDict_Next (arg , & pos , & key , & value ))
345+ lru_ass_sub (self , key , value );
346+ }
347+ }
348+
349+ if (kwargs != NULL && PyDict_Check (kwargs )) {
350+ while (PyDict_Next (kwargs , & pos , & key , & value ))
351+ lru_ass_sub (self , key , value );
352+ }
353+
354+ Py_RETURN_NONE ;
355+ }
356+
335357static PyObject *
336358LRU_peek_first_item (LRU * self )
337359{
@@ -483,6 +505,8 @@ static PyMethodDef LRU_methods[] = {
483505 PyDoc_STR ("L.peek_first_item() -> returns the MRU item (key,value) without changing key order" )},
484506 {"peek_last_item" , (PyCFunction )LRU_peek_last_item , METH_NOARGS ,
485507 PyDoc_STR ("L.peek_last_item() -> returns the LRU item (key,value) without changing key order" )},
508+ {"update" , (PyCFunction )LRU_update , METH_VARARGS | METH_KEYWORDS ,
509+ PyDoc_STR ("L.update() -> update value for key in LRU" )},
486510 {NULL , NULL },
487511};
488512
0 commit comments