Re: A couple of questions about pyrex

Greg Ewing <[email protected]> Wed, 13 May 2009 00:38:37 +1200
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
Yingjie Lan wrote:

> 1) Does pyrex support writing iterator classes for collection objects?

Yes. If you give an extension type a __next__ method, it
will get called in response to next(). Also, you can give
your collection class an __iter__ method just as in
Python.

> 2) Why not just
> use 'class MyClass' syntax for pyrex to define an extension?

If you write 'class MyClass' in Pyrex, you get an ordinary
Python class. Since that's the more Python-like behaviour,
it gets the more Python-like syntax.

The difference between 'def' and 'cdef' for functions is
that 'def' functions can be called from Python, whereas
'cdef' ones can't. Again, the more Python-like one gets
Python syntax.

-- 
Greg