-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Added LFU Cache #2151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added LFU Cache #2151
Conversation
Travis tests have failedHey @ruppysuppy, TravisBuddy Request Identifier: b7131530-b5e9-11ea-8cfa-25e523bed74d |
The comment said that None was returned but the failing test demonstrates that is not the case. |
@cclauss, when None is returned in python interpreter or doctests, its not shown. For example try this code in the interpreter:
Even though f returns None, running f() won't display None in the interpreter or doctests (unless |
|
||
|
||
class DoubleLinkedListNode: | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change '''
to """
in docstrings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autoblack will do this automatically so let's not slow the review process on this.
LFU Cache to store a given capacity of data. Can be used as a stand-alone object | ||
or as a function decorator. | ||
|
||
>>> cache = LFUCache(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could LFUCache
take optional cache parameter? Would be easier to test.
def __init__(self, capacity: int, cache: dict = None):
self.list = DoubleLinkedList()
self.capacity = capacity
self.num_keys = 0
self.hits = 0
self.miss = 0
self.cache = cache or {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems like a big change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Added LFU Cache * Update lfu_cache.py * None is returned * Add type hints Co-authored-by: Christian Clauss <cclauss@me.com>
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.