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
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
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
Mark Dickinson added the comment:
Opened https://bugs.pypy.org/issue1355 for this.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16791
___
___
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.
Changes by Danilo Bargen gez...@gmail.com:
--
nosy: +gwrtheyrn
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16791
___
___
Python-bugs-list
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
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
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: - rhettinger
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16791
___
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
10 matches
Mail list logo