-
-
Notifications
You must be signed in to change notification settings - Fork 324
Refactor out _tofile
/_fromfile
from DirectoryStore
#503
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor out _tofile
/_fromfile
from DirectoryStore
#503
Conversation
To make it easier to sub out different ways of reading and writing data, create to methods to handle reading and writing directly. This way users don't need to reimplement all of the same logic that `__getitem__` and `__setitem__` are doing and can focus on simply reading and writing. Can be useful for trying memmaping for example.
Co-Authored-By: James Bourbeau <jrbourbeau@users.noreply.github.com>
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! 🎉 I'm missing context on this, but is it worth making mode
a keyword argument which defaults to rb
/wb
or is there no situation where someone might need a different mode?
The idea would be subclasses could override |
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.
Thanks @jakirkham, this looks great and should definitely help with extending the DirectoryStore
! I've left one small documentation comment below. Also, could you please add a changelog entry? Otherwise LGTM
Thanks for the feedback. Have added two docstrings based on what you mentioned. Please let me know if there is anything else. 🙂 |
Planning on merging EOD tomorrow if no comments. |
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.
Thanks @jakirkham!
Thanks James! 😄 |
To make it easier for users to implement their own methods for reading and writing from disk ( like memory-mapping #377 ), refactor out
_tofile
and_fromfile
methods that are called to handle the reading and writing of the value. Should avoid duplicating a lot of other logic when trying to extendDirectoryStore
s for these cases.TODO:
tox -e docs
)