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

Add more dict methods to dbm interfaces #50295

Closed
birkenfeld opened this issue May 17, 2009 · 10 comments
Closed

Add more dict methods to dbm interfaces #50295

birkenfeld opened this issue May 17, 2009 · 10 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@birkenfeld
Copy link
Member

BPO 6045
Nosy @loewis, @birkenfeld, @pitrou, @merwok
Superseder
  • bpo-9523: Improve dbm modules
  • 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 = None
    closed_at = <Date 2011-02-04.00:56:40.284>
    created_at = <Date 2009-05-17.08:46:28.206>
    labels = ['type-feature', 'library']
    title = 'Add more dict methods to dbm interfaces'
    updated_at = <Date 2011-02-04.00:56:40.283>
    user = 'https://github.com/birkenfeld'

    bugs.python.org fields:

    activity = <Date 2011-02-04.00:56:40.283>
    actor = 'eric.araujo'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-02-04.00:56:40.284>
    closer = 'eric.araujo'
    components = ['Library (Lib)']
    creation = <Date 2009-05-17.08:46:28.206>
    creator = 'georg.brandl'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 6045
    keywords = []
    message_count = 10.0
    messages = ['87968', '87987', '87990', '87991', '87993', '87996', '91342', '123323', '123359', '127845']
    nosy_count = 6.0
    nosy_names = ['loewis', 'georg.brandl', 'pitrou', 'eric.araujo', 'foobaron', 'pablomouzo']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '9523'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue6045'
    versions = ['Python 3.3']

    @birkenfeld
    Copy link
    Member Author

    All the dbm.* modules currently have different interfaces, and different
    levels of supporting the Python3-style dictionary interface -- while the
    docs claim they all have (most of) the dict interface.

    For example, both dbm.gnu and dbm.ndbm only have keys() methods, and
    they return a list. Etc. for other dict-style methods.

    So, either we remove the claim that they have a dict-style interface
    beyond __*item__() and keys(), or we do something about it.

    @birkenfeld birkenfeld added release-blocker type-bug An unexpected behavior, bug, or error stdlib Python modules in the Lib dir labels May 17, 2009
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 17, 2009

    So, either we remove the claim that they have a dict-style interface
    beyond __*item__() and keys(), or we do something about it.

    I disagree that this is release-critical. I think it is desirable to
    say that the dbm modules support most of a dict-style interface,
    and I also think that it is factually correct to claim that they
    currently do.

    The problem with the current documentation is that it apparently stopped
    documenting the "dict-style interface", in the sense

    http://www.python.org/doc/2.5/lib/typesmapping.html

    did. Instead, the documentation now only documents the dict type itself.
    If a dict-style interface was specified, one would have to specify
    whether returning views from keys/values/items is part of the dict-style
    interface or not.

    @birkenfeld
    Copy link
    Member Author

    First, lowering priority.

    I disagree that this is release-critical. I think it is desirable to
    say that the dbm modules support most of a dict-style interface,
    and I also think that it is factually correct to claim that they
    currently do.

    Supporting only __getitem__, __setitem__, __delitem__, __contains__ and
    keys is already "most of a dict-style interface"? Only dumbdbm and
    bsddb, which isn't in the core anymore, support more methods.

    The problem with the current documentation is that it apparently stopped
    documenting the "dict-style interface", in the sense
    http://www.python.org/doc/2.5/lib/typesmapping.html
    did. Instead, the documentation now only documents the dict type itself.
    If a dict-style interface was specified, one would have to specify
    whether returning views from keys/values/items is part of the dict-style
    interface or not.

    It should first be decided what a "dict-style interface" means in Python
    3, then I can document it :)

    However, for the dbm modules I would be in favor of only specifying the
    four mentioned methods, as in the docstring of dbm/init.py, and not
    claiming any more.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 17, 2009

    > I disagree that this is release-critical. I think it is desirable to
    > say that the dbm modules support most of a dict-style interface,
    > and I also think that it is factually correct to claim that they
    > currently do.

    Supporting only __getitem__, __setitem__, __delitem__, __contains__ and
    keys is already "most of a dict-style interface"?

    It's also __len__... Indeed, I think that this is the major part of the
    dict interface. For a number of additional methods, it would be
    straight-forward to support them as well (such as get(), pop(),
    popitem(), setdefault(), update()). That they are missing should be
    considered as a regular bug/missing feature. However, it appears that
    nobody has complained about those missing features in all these years,
    so that they are missing can't be that serious.

    However, for the dbm modules I would be in favor of only specifying the
    four mentioned methods, as in the docstring of dbm/init.py, and not
    claiming any more.

    I don't mind the documentation to explain precisely what is, as long as
    it continues to explain what could be.

    @pitrou
    Copy link
    Member

    pitrou commented May 17, 2009

    Would inheriting from MutableMapping fix this problem?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented May 17, 2009

    Would inheriting from MutableMapping fix this problem?

    In principle: some of it, yes. These types are written in C,
    so I'm not sure how exactly it would work. Also, it
    still wouldn't provide all methods, e.g. copy(), fromkeys(),
    get(), values(), items() would still be missing, as would
    iteration (although the dict documentation apparently never
    says that iterating over a dict is supported).

    @foobaron
    Copy link
    Mannequin

    foobaron mannequin commented Aug 6, 2009

    I suspect that for most users, shelve is the main way they will access
    the dbm.* interfaces. Based on that, the dict methods that are really
    needed on dbm.* objects are just: __iter__, __len__, __getitem__,
    __setitem__, __delitem__, __contains__, has_key, and keys.

    Note: bpo-5736 aims to make dbm.* support the iterator protocol, which
    would be crucial for making shelve iteration scalable (currently,
    iterating on a Shelf will call self.dict.keys(), loading the entire
    index into memory!).

    The dbm.* docs could also explicitly tell users who want a *complete*
    dict interface to create a class that inherits from both dbm and
    UserDict.DictMixin / MutableMapping.

    @birkenfeld
    Copy link
    Member Author

    r87013 adds get() and setdefault() to dbm.gnu -- now gdbm and ndbm have the same set of dict methods available.

    For me, that is enough to demote this to feature request.

    There's another issue anyway for iteration protocol support.

    @birkenfeld birkenfeld changed the title Fix dbm interfaces Add more dict methods to dbm interfaces Dec 4, 2010
    @birkenfeld birkenfeld added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Dec 4, 2010
    @merwok
    Copy link
    Member

    merwok commented Dec 4, 2010

    See also bpo-9523.

    @merwok
    Copy link
    Member

    merwok commented Feb 4, 2011

    I believe this is now superseded by bpo-9523, which has less discussion but a patch.

    @merwok merwok closed this as completed Feb 4, 2011
    @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
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants