Issue 26557: dictviews methods not present on shelve objects (original) (raw)

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:28 admin set github: 70744
2016-09-12 03:38:47 rhettinger set status: open -> closedresolution: fixed
2016-09-12 03:38:35 python-dev set nosy: + python-devmessages: +
2016-09-12 02:24:16 thomir set files: + issue26557_userdict.patchmessages: +
2016-09-12 02:23:22 rhettinger set priority: normal -> lownosy: + rhettingermessages: + assignee: docs@python -> rhettinger
2016-09-12 02:20:52 thomir set files: + issue26557_shelve.patchnosy: + thomirmessages: + keywords: + patch
2016-03-14 11:27:11 serhiy.storchaka set assignee: docs@pythoncomponents: + Documentation, - Library (Lib)keywords: + easynosy: + serhiy.storchaka, docs@pythonmessages: + stage: needs patch
2016-03-14 11:19:00 Michael Crouch create