Message128277
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. |
|
| Date |
User |
Action |
Args |
| 2011-02-10 10:27:07 | ysj.ray | set | recipients:
+ ysj.ray, georg.brandl, rhettinger, terry.reedy, eric.araujo, r.david.murray, Kain94 |
| 2011-02-10 10:27:06 | ysj.ray | set | messageid: <1297333626.36.0.473320329177.issue9523@psf.upfronthosting.co.za> |
| 2011-02-10 10:27:05 | ysj.ray | link | issue9523 messages |
| 2011-02-10 10:27:05 | ysj.ray | create | |
|