<div dir="ltr">On Fri, Feb 8, 2013 at 11:13 PM, Siddharth Agarwal <<a href="mailto:sid0@fb.com">sid0@fb.com</a>> wrote:<br>><br>> # HG changeset patch<br>> # User Siddharth Agarwal <<a href="mailto:sid0@fb.com">sid0@fb.com</a>><br>
> # Date 1360351263 0<br>> # Node ID 642bf4f92100a41182de15646e37db70b391bfeb<br>> # Parent  08e00496e7b3bda8db3fbe7084a013d77e4932d2<br>> util: add an LRU cache dict<br>><br>> This is the bare minimum dictionary implementation needed for an upcoming<br>
> patch.<br>><br>> diff --git a/mercurial/util.py b/mercurial/util.py<br>> --- a/mercurial/util.py<br>> +++ b/mercurial/util.py<br>> @@ -211,6 +211,30 @@ except AttributeError:<br>>                      del self[i]<br>
>                      break<br>><br>> +class lrucachedict(object):<br>> +    '''cache most recent get or sets to this dictionary'''<br>> +    def __init__(self, size):<br>> +        self._cache = {}<br>
> +        self._size = {}<br>> +        self._order = deque()<div><br></div><div>Looks like you forgot to assign to _size here, so your</div><div>LRU isn't really bounded :)</div><div><br></div><div>>>> 0 > {}</div>
<div>False</div></div>