[Python-Dev] Change to PyIter_Next()? (original) (raw)
Tim Peters tim.one@home.com
Fri, 4 May 2001 17🔞16 -0400
- Previous message: [Python-Dev] Change to PyIter_Next()?
- Next message: [Python-Dev] ::
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Tim]
In spare moments, I've been plugging away at ... iterators
[Guido]
For which efforts I extend my greatest thanks!
Yet but a pale reflection of the thanks I extend to you for implementing these guys to begin with: they're loads of fun! But not nearly as much fun as playing with Perl, so they're still prudently Pythonic .
[T proposed adding a int* error arg to PyIter_Next()]
[G]
How about making PyIterNext() call PyErrClear() when the exception is StopIteration?
Then calls could be op2 = PyIterNext(it); if (op2 == NULL) { if (PyErrOccurred()) goto Fail; break; }
Perfect. I'll do that later tonight, and update the PEP to match.
This is a tad slower and arguably generates more code (assuming an extra call is slower than passing an extra argument and loading it) but doesn't require declaring the error variable.
Well, it's two more calls (since PyErr_Occurred() also makes a call to get the thread state), but I don't really care because the client only does this in case of error or end-of-iteration (which aren't the normal cases). I was dreading finding a spare int var to pass inside FOR_ITER anyway .
- Previous message: [Python-Dev] Change to PyIter_Next()?
- Next message: [Python-Dev] ::
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]