[Cython] __next__ | not being able to use cpdef

Jelle Feringa jelleferinga at gmail.com
Sat Dec 6 19:38:08 CET 2008


> I __next__ falls in the category of special methods, please read the  
> fine docs
> http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/special_methods.html

Right, I've read the document.

> Declare __next__ with 'def', they are treated specially and are as
> fast as the CPython implementation permits.

Aha, I see, that I didn't know.
I noticed that the cython iterator is about twice as fast compared to  
the python version, when indexing an iterable object.
A respectable speedup, given how trivial the implementation is. Would  
you consider the implementation optimal? Is this the fastest way of  
indexing an iterable object?

Many thanks Lisandro.

-jelle



More information about the Cython-dev mailing list