Interesting concept! I'm experimenting with this have and have noticed a few potential issues. Currently TrackingDict doesn't respond to the .get() method, an easy fix there might be inheriting from UserDict or refactoring to implement a MutableMapping? Another thing I noticed is that key lookup misses also get added to the _accessed_keys set. ex: a lookup to user["address"] wrapped in a try/except KeyError. This might be the desired behavior though?
Comment
Interesting concept! I'm experimenting with this have and have noticed a few potential issues. Currently TrackingDict doesn't respond to the .get() method, an easy fix there might be inheriting from UserDict or refactoring to implement a MutableMapping? Another thing I noticed is that key lookup misses also get added to the _accessed_keys set. ex: a lookup to user["address"] wrapped in a try/except KeyError. This might be the desired behavior though?
Replies
That's great points! The origin place where I wanted and needed this was only using `__getitem__` so I didn't think of `.get()`.