[issue9523] Improve dbm modules

Éric Araujo report at bugs.python.org
Thu Feb 10 23:09:49 CET 2011


Éric Araujo <merwok at netwok.org> added the comment:

> 1. Make keys(), values(), items() methods return view object for
> ndbm, gdbm and dumb objects. I following the codes in dictobject.c.
Did you have to copy the code?  Isn’t it possible to somehow reuse it?

> The keysview object support len(), "in" operator, and iteratable,
> while valuesview and itemsview object only support len() and iteratable.
That does not seem to comply with the definition of dict views.  Do the views yield elements in the same order?  (In a dict, iteration order is undefined but consistent between the various views, IIUC.)

> 3. Remove dumb's keys() method which calls self._index.keys() since it is unnecessary.
Does dumb have no keys method then?

> 4. Using more specialized assertXxx methods in test cases.
See my comments on http://codereview.appspot.com/4185044/

> #5736 's patch for adding iteration to ndbm and gdbm modules simple
> calling PyObject_GetIter(dbm_keys(dbm, NULL)) for both gdbm and ndbm,
> but I feel it's better to create a seperate iterator object for gdbm objects.
Okay, so I shall close the other bug report, indicating it’s superseded by your patch.

I can’t judge the C code; maybe Raymond or Daniel will.  They’re also experts about collections and ABCs, so they’ll be able to confirm or infirm what I’ve said about dict views and the registration stuff (on codereview).

----------
nosy: +stutzbach

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9523>
_______________________________________


More information about the Python-bugs-list mailing list