Skip to content
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

dictviews methods not present on shelve objects #70744

Closed
MichaelCrouch mannequin opened this issue Mar 14, 2016 · 6 comments
Closed

dictviews methods not present on shelve objects #70744

MichaelCrouch mannequin opened this issue Mar 14, 2016 · 6 comments
Assignees
Labels
docs Documentation in the Doc dir easy

Comments

@MichaelCrouch
Copy link
Mannequin

MichaelCrouch mannequin commented Mar 14, 2016

BPO 26557
Nosy @rhettinger, @serhiy-storchaka
Files
  • issue26557_shelve.patch
  • issue26557_userdict.patch
  • 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:

    assignee = 'https://github.com/rhettinger'
    closed_at = <Date 2016-09-12.03:38:47.017>
    created_at = <Date 2016-03-14.11:19:00.538>
    labels = ['easy', 'docs']
    title = 'dictviews methods not present on shelve objects'
    updated_at = <Date 2016-09-12.03:38:47.016>
    user = 'https://bugs.python.org/MichaelCrouch'

    bugs.python.org fields:

    activity = <Date 2016-09-12.03:38:47.016>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2016-09-12.03:38:47.017>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2016-03-14.11:19:00.538>
    creator = 'Michael Crouch'
    dependencies = []
    files = ['44578', '44580']
    hgrepos = []
    issue_num = 26557
    keywords = ['patch', 'easy']
    message_count = 6.0
    messages = ['261744', '261745', '275918', '275920', '275921', '275941']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'docs@python', 'python-dev', 'serhiy.storchaka', 'thomir', 'Michael Crouch']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = 'needs patch'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue26557'
    versions = ['Python 2.7']

    @MichaelCrouch
    Copy link
    Mannequin Author

    MichaelCrouch mannequin commented Mar 14, 2016

    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).

    @MichaelCrouch MichaelCrouch mannequin added the stdlib Python modules in the Lib dir label Mar 14, 2016
    @serhiy-storchaka
    Copy link
    Member

    The shelve object inherits its dict-like methods from UserDict.DictMixin. The documentation for UserDict.DictMixin should be updated too.

    @serhiy-storchaka serhiy-storchaka added easy docs Documentation in the Doc dir and removed stdlib Python modules in the Lib dir labels Mar 14, 2016
    @thomir
    Copy link
    Mannequin

    thomir mannequin commented Sep 12, 2016

    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).

    @rhettinger
    Copy link
    Contributor

    This patch looks fine.

    @rhettinger rhettinger assigned rhettinger and unassigned docspython Sep 12, 2016
    @thomir
    Copy link
    Mannequin

    thomir mannequin commented Sep 12, 2016

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 12, 2016

    New changeset 2b4bfef0d54a by Raymond Hettinger in branch '2.7':
    Issue bpo-26557: Note that mapping view methods are not present in UserDict or shelves.
    https://hg.python.org/cpython/rev/2b4bfef0d54a

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir easy
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants