[issue5736] Add the iterator protocol to dbm modules

2011-02-12 Thread Éric Araujo
Éric Araujo added the comment: #9523 has a more comprehensive patch in progress, adding __iter__ and other mapping methods, so I’m closing this one. -- resolution: -> duplicate stage: -> committed/rejected status: open -> closed superseder: -> Improve dbm modules versions: -Python

[issue5736] Add the iterator protocol to dbm modules

2010-12-04 Thread Éric Araujo
Éric Araujo added the comment: This may be superseded by #9523. There are comments and patches in both issues, so I’m not closing either as duplicate of the other. -- nosy: +eric.araujo ___ Python tracker ___

[issue5736] Add the iterator protocol to dbm modules

2010-10-18 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue5736] Add the iterator protocol to dbm modules

2010-10-16 Thread Akira Kitada
Akira Kitada added the comment: This patch just uses PyObject_GetIter to get an iter. (I just copied the idea from issue9523) -- nosy: +ysj.ray versions: +Python 3.2 -Python 2.7 Added file: http://bugs.python.org/file19250/issue5736.diff ___ Python t

[issue5736] Add the iterator protocol to dbm modules

2010-10-16 Thread Akira Kitada
Changes by Akira Kitada : Removed file: http://bugs.python.org/file13676/issue5736.diff ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue5736] Add the iterator protocol to dbm modules

2010-10-16 Thread Akira Kitada
Changes by Akira Kitada : Removed file: http://bugs.python.org/file13682/test_issue5736.diff ___ Python tracker ___ ___ Python-bugs-list mailin

[issue5736] Add the iterator protocol to dbm modules

2010-10-16 Thread Akira Kitada
Changes by Akira Kitada : Removed file: http://bugs.python.org/file13674/issue5736.diff ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue5736] Add the iterator protocol to dbm modules

2010-10-16 Thread Akira Kitada
Changes by Akira Kitada : Removed file: http://bugs.python.org/file13673/issue5736.diff ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue5736] Add the iterator protocol to dbm modules

2010-05-20 Thread Skip Montanaro
Changes by Skip Montanaro : -- nosy: -skip.montanaro ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue5736] Add the iterator protocol to dbm modules

2009-08-05 Thread Christopher Lee
Christopher Lee added the comment: Another reason this issue is really important, is that the lack of a consistent iter() interface for dbm.* makes shelve iteration not scalable; i.e. trying to iterate on a Shelf will run self.dict.keys() to load the entire index into memory. This seems contrar

[issue5736] Add the iterator protocol to dbm modules

2009-04-13 Thread Akira Kitada
Akira Kitada added the comment: Yes, using a static variable there is wrong and actually I'm now working on "dbm_iterobject" just as Martin suggested. dbm iterator should behave just like one in dict. I think I can use Objects/dictobject.c as a good example for this. Attached is minimal tests

[issue5736] Add the iterator protocol to dbm modules

2009-04-13 Thread Martin v. Löwis
Martin v. Löwis added the comment: I agree with Skip that using a static variable is not appropriate. The proper solution probably would be to define a separate gdbm_iter object which always preserves the last key returned. -- ___ Python tracker

[issue5736] Add the iterator protocol to dbm modules

2009-04-12 Thread Skip Montanaro
Skip Montanaro added the comment: skip> What's worse, even in a non-threaded environment you might want to skip> iterate over the gdbm file simultaneously from two different skip> places. Or iterate over two different gdbm files simultaneously. -- _

[issue5736] Add the iterator protocol to dbm modules

2009-04-12 Thread Skip Montanaro
Skip Montanaro added the comment: Akira> Note that dbm and gdbm C API is a little different. gdbm_nextkey Akira> requires key for its argument, dbm_nextkey don't. So I had to Akira> use for gdbm an static variable that points to the current Akira> position. I don't think this is g

[issue5736] Add the iterator protocol to dbm modules

2009-04-12 Thread Akira Kitada
Akira Kitada added the comment: Of course iter should work in the same way in all dbm modules. iter in dbm/gdbm should work like dumbdbm's iter. >>> dumb = dumbdbm.open('foo', 'n') >>> dumb['k1'] = 'v1';dumb['k2'] = 'v2'; >>> for i in dumb: print i; break ... k2 >>> for i in dumb: print i for

[issue5736] Add the iterator protocol to dbm modules

2009-04-12 Thread Akira Kitada
Akira Kitada added the comment: Here's another patch which addsd iter to dbm and gdbm. Note that dbm and gdbm C API is a little different. gdbm_nextkey requires key for its argument, dbm_nextkey don't. So I had to use for gdbm an static variable that points to the current position. Now iterator

[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Martin v. Löwis
Martin v. Löwis added the comment: Would you like to fix gdbm as well? -- nosy: +loewis ___ Python tracker ___ ___ Python-bugs-list ma

[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Akira Kitada
Akira Kitada added the comment: Revised patch adds firstkey and nextkey to dbm. Now the internal pointer can be reset with firstkey. -- Added file: http://bugs.python.org/file13674/issue5736.diff ___ Python tracker

[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Akira Kitada
Akira Kitada added the comment: Attached is a patch that adds the iterator protocol. Now it can be interated through like: >>> for k in d: print k, d[k] ... key1 vale1 key3 vale3 key0 vale0 key2 vale2 key4 vale4 The problem is there is no way to get the internal pointer back to the start. So

[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Akira Kitada
New submission from Akira Kitada : In Python 2.6, dbm modules othar than bsddb don't support the iterator protocol. >>> import dbm >>> d = dbm.open('spam.dbm', 'c') >>> for k in range(5): d["key%d" % k] = "value%d" % k ... >>> for k in d: print k, d[k] ... Traceback (most recent call last):