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
>
>
> On Mon, Dec 8, 2008 at 2:24 PM, Jelle Feringa <[EMAIL PROTECTED]> wrote:
>>>> Out of curiosity, would most of the time be spent on the line "return
>>>> self.obj[self.i]"? It seems like a __getitem__ call would be much
>>>> slower than anything else in the class.
>>>
>>> Yes, almost certainly.
>>
>> Hi Aaron, Robert,
>>
>> Thanks for your response; any suggestion what might be more efficient
>> than a __getitem__ call?
>> Or is this class doomed by design?
>>
>> Cheers,
>>
>> -jelle
>> _______________________________________________
>> Cython-dev mailing list
>> [email protected]
>> http://codespeak.net/mailman/listinfo/cython-dev
>>
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to