Author ysj.ray
Recipients Kain94, eric.araujo, georg.brandl, r.david.murray, rhettinger, terry.reedy, ysj.ray
Date 2011-02-10.10:27:03
SpamBayes Score 3.87089e-06
Marked as misclassified No
Message-id <1297333626.36.0.473320329177.issue9523@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-02-10 10:27:07ysj.raysetrecipients: + ysj.ray, georg.brandl, rhettinger, terry.reedy, eric.araujo, r.david.murray, Kain94
2011-02-10 10:27:06ysj.raysetmessageid: <1297333626.36.0.473320329177.issue9523@psf.upfronthosting.co.za>
2011-02-10 10:27:05ysj.raylinkissue9523 messages
2011-02-10 10:27:05ysj.raycreate