Ray.Allen <[email protected]> added the comment:
Thanks eric for reviewing my patch! And thanks for you suggestions. I'm
following them.
> I don’t know if you should use a plain set or a collections.ItemsView here.
> In dict objects, KeysView and ValuesView are set-like objects with added
> behavior, for example they yield their elements in the same order.
Yes you are right. I think returning a view object is better than returning a
set.
Here is the updated patch. It updates:
1. Make keys(), values(), items() methods return view object for ndbm, gdbm and
dumb objects. I following the codes in dictobject.c. The keysview object
support len(), "in" operator, and iteratable, while valuesview and itemsview
object only support len() and iteratable.
2. Removing doc changes:
The object returned by :func:`.open` supports the same basic functionality as
-dictionaries
+:mod:`collection`.MutableMapping
which is mentioned in eric's comment.
3. Remove dumb's keys() method which calls self._index.keys() since it is
unnecessary.
4. Using more specialized assertXxx methods in test cases.
5. Remove "the values() and items() method are not supported" in
Doc/library/dbm.rst.
> See #5736 for a patch adding iteration support. If the patch attached to his
> report supersedes the other one, I’ll close the other bug as duplicate.
#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.
----------
Added file: http://bugs.python.org/file20726/issue_9523.diff
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9523>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com