You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since items are only removed on retrieval, calling the len method on the dictionary will return all the items in the dictionary--including the expired items.
Length should iterate through the internal list and find what items are expired and remove them appropriately. Since it's internally implemented using an OrderedDict, we can perform a binary search to find what items in the dictionary have expired in Log(n) time
The text was updated successfully, but these errors were encountered:
PR #40 fixes it. Doesn't use binary search approach yet. setitem cleans up implicitly, so amortized, it should be fast enough. If it makes a big performance impact, we know what algorithm would work best.
I've noticed the bug still persists. The len() function applied to the ExpiringDict object doesn't return the expected value unless the same function is applied to the list of values first.
@lucascott - Thats how its supposed to work, afaik. Expiring items are removed when the next mutating operation happens, so for a while they'll still claim memory.
Since items are only removed on retrieval, calling the
len
method on the dictionary will return all the items in the dictionary--including the expired items.Length should iterate through the internal list and find what items are expired and remove them appropriately. Since it's internally implemented using an
OrderedDict
, we can perform a binary search to find what items in the dictionary have expired in Log(n) timeThe text was updated successfully, but these errors were encountered: