Right, but this isn't any different from looping through a vanilla  
python iterable, right?
Simply typing the number that indexes the iterable already loops twice  
as fast, although obviously its rather trivial code.
Actually, it would be interesting to see if a fast __getitem__ call  
would be available, since that would facilitate writing fast  
specialized iterators easily.

-jelle

On Dec 9, 2008, at 12:42 AM, Aaron DeVore wrote:

> That code example needs a bit of a modification.
>
> class Foo:
>   def __init__(self):
>      self.contents = []
>   # ...code that manipulates self.contents...
>   def chunk(self, n):
>      return iter(self.contents[:n])
>
> On Mon, Dec 8, 2008 at 3:31 PM, Aaron DeVore  
> <[EMAIL PROTECTED]> wrote:
>> If there's an internal Python/extension type data structure you could
>> use the iterator from that.
>>
>> class Foo:
>>   def __init__(self):
>>       self.var = []
>>   def __iter__(self):
>>       return iter(self.var)
>>
>> Besides that I can't think of anything.
>>
>> -Aaron
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to