Re: [Python-Dev] Short-circuiting iterators

2005-12-07 Thread Matthew F. Barnes
On Tue, 2005-12-06 at 19:58 -0500, Raymond Hettinger wrote: > Any real-world use cases or compelling contrived examples? > > ISTM, that the code calling it.stop() would already be in position to > break-out of the iteration directly or set a termination flag. Instead > of: > > it = itertools

Re: [Python-Dev] Short-circuiting iterators

2005-11-30 Thread Matthew F. Barnes
On Wed, 2005-11-30 at 14:36 -0500, Edward Loper wrote: > There's no need to change the iterator protocol for your example use > case; you could just define a simple iterator-wrapper: Good point. Perhaps it would be a useful addition to the itertools module then? itertools.interruptable(

Re: [Python-Dev] Short-circuiting iterators

2005-11-30 Thread Matthew F. Barnes
On Wed, 2005-11-30 at 10:57 -0800, Alex Martelli wrote: > PEP 342, already accepted and found at > http://python.org/peps/pep-0342.html , covers related functionality > (as well as many other points). Thanks Alex, I'll take another look at that PEP. The first time I tried to read it my brain star

[Python-Dev] Short-circuiting iterators

2005-11-30 Thread Matthew F. Barnes
Hello, I've not had much luck in searching for a discussion on this in the Python-Dev archives, so bear with me. I had an idea this morning for a simple extension to Python's iterator protocol that would allow the user to force an iterator to raise StopIteration on the next call to next(). My th

[Python-Dev] Lexical analysis and NEWLINE tokens

2005-10-06 Thread Matthew F. Barnes
I posted this question to python-help, but I think I have a better chance of getting the answer here. I'm looking for clarification on when NEWLINE tokens are generated during lexical analysis of Python source code. In particular, I'm confused about some of the top-level components in Python's gr

Re: [Python-Dev] Reference counting when entering and exiting scopes

2005-04-21 Thread Matthew F. Barnes
On Wed, 2005-04-20 at 18:59 -0700, Brett C. wrote: > So no leak. Yes, there should be more explicit refcounting to be proper, but > the compiler cheats in a couple of places for various reasons. But basically > everything is fine since st->st_cur and st->st_stack are only played with > refcount-w

[Python-Dev] Reference counting when entering and exiting scopes

2005-04-20 Thread Matthew F. Barnes
Someone on python-help suggested that I forward this question to python-dev. I've been studying Python's core compiler and bytecode interpreter as a model for my own interpreted language, and I've come across what appears to be a reference counting problem in the `symtable_exit_scope' function in