Hallo all, I have a question about the standard objectspace interface. It's about how to best return an iterator. While writing the 'set' implementation, it occured to me, that I'm using a W_SeqIterObject directly, which is bad, since this breaks the intended separation of types / objects. Instead, I'd like to use something like space.newseqiter. But 'newseqiter' takes a wrapped object, while I'd rather use a way to 'translate' some interp level iterator of wrapped objects directly to an application lever iterator. This would be similar to newlist which creates an application level list of application level objects out of an interp level list of application level objects. Or is the dictobject way the preferred one? There we have special iterator object 'W_DictIter_Keys', for example. I hope I make a bit of sense. Cheers Stephan
Hi Stephan, On Fri, Apr 07, 2006 at 06:16:39PM +0200, Stephan Diehl wrote:
space.newseqiter.
This is only for iterating over sequences, just like W_SeqIterObject.
Or is the dictobject way the preferred one? There we have special iterator object 'W_DictIter_Keys', for example.
Yes, you need a special iterator class like W_DictIter_Keys. BTW, W_SetObject.data, which is an r_dict, should ideally have 'None' as keys instead of space.w_True. This would make the low-level translated code more memory-efficient, by using 'void' values instead of pointers to space.w_True. A bientot, Armin.
On Friday 07 April 2006 18:43, Armin Rigo wrote:
Hi Stephan,
On Fri, Apr 07, 2006 at 06:16:39PM +0200, Stephan Diehl wrote:
space.newseqiter.
This is only for iterating over sequences, just like W_SeqIterObject.
Or is the dictobject way the preferred one? There we have special iterator object 'W_DictIter_Keys', for example.
Yes, you need a special iterator class like W_DictIter_Keys.
o.k.
BTW, W_SetObject.data, which is an r_dict, should ideally have 'None' as keys instead of space.w_True. This would make the low-level translated code more memory-efficient, by using 'void' values instead of pointers to space.w_True.
ahh, good point, I'll change that then (the other stuff, we talked about last week, is already changed, but not checked in) Thanks Stephan
A bientot,
Armin.
participants (2)
-
Armin Rigo
-
Stephan Diehl