-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add reversed keys(), items(), values() to sqlitedict #173
Comments
I don't think these methods are a part of the Python dict API, are they? Sqlitedict's goal is to be a "dict with commit". So its gracefulness should mimic that of dict, for better or worse. |
With Python dict, you can do this:
aslo you can refere to this: https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects Right now, to access the latest entries, I have to dump all the data in sqlitedict into a list, and then reverse the list. |
OK, that If that's the case we could support it too. But we'd want to use the same API, rather than invent new methods (that users will never know about). |
It would be great if that could be supported and consistent with dict! |
@mpenkov do you know how that works? Any way to supply our own @jiangwen365 can you look into it & open a PR? We probably won't have time for this in the near future. |
I would like to suggest adding reversed methods to sqlitedict, such as reversed_keys(), reversed_items(), and reversed_values(). Currently, there are no built-in ways to get content in reverse order from sqlitedict, and I think it would be graceful and more efficient to have such methods available.
Having reversed methods would be useful for various use cases, such as iterating over a sqlitedict in reverse order, finding the last item in a dict, or checking if a dict contains a certain item from the end.
I believe that adding reversed methods would be relatively easy to implement by adding the DESC keyword to the underlying SQL statements used by sqlitedict. This would allow for efficient and performant reversed queries without introducing significant overhead.
Overall, I think that adding reversed methods to sqlitedict would be a valuable addition to the library and would improve its usability and flexibility.
Thank you for considering this suggestion.
The text was updated successfully, but these errors were encountered: