[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-28 Thread R. David Murray
R. David Murray added the comment: If it is a feature, then is it documented in the language reference and is this actually a bug in PyPy (it sounds like it is)? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16791

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-28 Thread Mark Dickinson
Mark Dickinson added the comment: It looks to me as though this has nothing to do with itertools In CPython 2.7: Python 2.7.3 |EPD 7.3-1 (32-bit)| (default, Apr 12 2012, 11:28:34) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type credits, demo or enthought for more information. b = [1] b

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-28 Thread Mark Dickinson
Mark Dickinson added the comment: And here's a non-infinite example where CPython and PyPy differ. Python 2.7.3 |EPD 7.3-1 (32-bit)| (default, Apr 12 2012, 11:28:34) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type credits, demo or enthought for more information. b = [1] b += (x+1 for x in

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-28 Thread Mark Dickinson
Mark Dickinson added the comment: Opened https://bugs.pypy.org/issue1355 for this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16791 ___ ___

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread David Halter
New submission from David Halter: The following lines run infinitely: b = [1] import itertools b += itertools.chain.from_iterable([c] for c in b) In my opinion this is a bug. Clearly you could say that this is an implementation detail. But afaik this is not documented and very misleading.

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread Danilo Bargen
Changes by Danilo Bargen gez...@gmail.com: -- nosy: +gwrtheyrn ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16791 ___ ___ Python-bugs-list

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread pyos
pyos added the comment: I don't think this is a bug. `b += iter(b)` and `for c in b: b.append(c)` work the same way. Also, the tutorial makes it clear that you should duplicate the list if you modify it inside a loop; in this case, this can be done either by iterating over `b[:]` instead of

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread R. David Murray
R. David Murray added the comment: Yes, the behavior here is undefined at the language level. And as pyos says, technically it is documented: if you mutate the object over which you are iterating inside the iteration context (a for loop is just one example of same), the behavior is

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread Raymond Hettinger
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- assignee: - rhettinger nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16791 ___

[issue16791] itertools.chain.from_iterable doesn't stop

2012-12-27 Thread Raymond Hettinger
Raymond Hettinger added the comment: This isn't a bug. It is an intended feature that chain.from_iterable evaluates lazily (and is documented as such). The pure python equivalent in the docs behaves the same as the C version does. Also, it is a long standing feature of lists that you can