This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dictviews methods not present on shelve objects
Type: Stage: needs patch
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Michael Crouch, docs@python, python-dev, rhettinger, serhiy.storchaka, thomir
Priority: low Keywords: easy, patch

Created on 2016-03-14 11:19 by Michael Crouch, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue26557_shelve.patch thomir, 2016-09-12 02:20
issue26557_userdict.patch thomir, 2016-09-12 02:24
Messages (6)
msg261744 - (view) Author: Michael Crouch (Michael Crouch) Date: 2016-03-14 11:19
Shelve types in Python 2.7 don't implement the 'viewkeys', 'viewvalues', and 'viewitems' methods.

Section 11.4 of the Python Standard Library documentation says that "Shelf objects support all methods supported by dictionaries." If those methods can't be added to shelves, the documentation should be clarified.

The use case for this was that I wanted an iterator on a shelf that didn't try to materialize the entire list (since the shelf is very large and I'd prefer to leave most of it on disk).
msg261745 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-14 11:27
The shelve object inherits its dict-like methods from UserDict.DictMixin. The documentation for UserDict.DictMixin should be updated too.
msg275918 - (view) Author: Thomi Richards (thomir) * Date: 2016-09-12 02:20
Attached is a patch that adds documentation to `shelve.rst` explicitly stating that it does not support the viewkeys, viewvalues, and viewitems methods. 

I think this is the correct approach since it doesn't seems sensible to add support for these methods to UserDict, *and* also it might give users the impression that they can incrementally iterate over a shelved object without loading it all (which I believe is incorrect).
msg275920 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2016-09-12 02:23
This patch looks fine.
msg275921 - (view) Author: Thomi Richards (thomir) * Date: 2016-09-12 02:24
Attached is a patch that adds a sentence to the UserDict module docs explicitly stating that the viewkeys, viewitems, and viewvalues functions are not implemented. I don't think it's worth adding support for these newer functions in UserDict. I'm unsure whether landing this patch is as necessary as the patch for the shelve module.
msg275941 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-12 03:38
New changeset 2b4bfef0d54a by Raymond Hettinger in branch '2.7':
Issue #26557:  Note that mapping view methods are not present in UserDict or shelves.
https://hg.python.org/cpython/rev/2b4bfef0d54a
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70744
2016-09-12 03:38:47rhettingersetstatus: open -> closed
resolution: fixed
2016-09-12 03:38:35python-devsetnosy: + python-dev
messages: + msg275941
2016-09-12 02:24:16thomirsetfiles: + issue26557_userdict.patch

messages: + msg275921
2016-09-12 02:23:22rhettingersetpriority: normal -> low

nosy: + rhettinger
messages: + msg275920

assignee: docs@python -> rhettinger
2016-09-12 02:20:52thomirsetfiles: + issue26557_shelve.patch

nosy: + thomir
messages: + msg275918

keywords: + patch
2016-03-14 11:27:11serhiy.storchakasetassignee: docs@python
components: + Documentation, - Library (Lib)

keywords: + easy
nosy: + serhiy.storchaka, docs@python
messages: + msg261745
stage: needs patch
2016-03-14 11:19:00Michael Crouchcreate