[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 <wink>. [T proposed adding a int* error arg to PyIter_Next()] [G] > How about making PyIter_Next() call PyErr_Clear() when the exception > is StopIteration? > > Then calls could be > > op2 = PyIter_Next(it); > if (op2 == NULL) { > if (PyErr_Occurred()) > 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 <wink>.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4