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
Should shelve support dict union? #87609
Comments
The docs of shelve mention that
However the Otherwise the docs could be updated. |
The comment is outdated. Shelf objects also do not support methods copy and fromkey. Creating a new Shelve object without specifying a new underlying database object does not make much sense. Maybe say that they implement the MutableMapping interface? >>> sorted(set(dir(dict)) - set(dir(shelve.Shelf)))
['__ior__', '__or__', '__ror__', 'copy', 'fromkeys']
>>> sorted(set(dir(collections.abc.MutableMapping)) - set(dir(shelve.Shelf)))
[] |
Right, that seems like a good idea. But |
Yes, that's a good idea (also add link to the MutableMapping docs).
Off-hand, I don't see why not. Adding Brandt to the nosy list to see what he thinks. |
One other thought. While __ior__() could be used as a short-cut for update(), the related __or__() method is more problematic because it would need to create a new underlying DB. So maybe this is a can worms that we should not open. It would be weird to have __ior__() but not __or__(). |
+1 for the MutableMapping comment. We purposely omitted shelve when determining what classes should grow the new operators. Guido's thoughts:
(https://bugs.python.org/msg364196) I personally have no experience with shelve, so I'd rather defer to the judgement of others here. |
It's true, having
For my use cases, however, I always knew right from the beginning that I want object persistence between different runs of a script (e.g. for data analysis, caching the expensive results), so it was always clear that I'm working with a Shelf object and not a dict (i.e. no expectations on the availability of Primarily, this issue was meant to point out the mismatch of docs/implementation and not to get |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: