It is not fake. If your iterator uses a reference to
the underlying list, then the behavior is different
sage: l = []
sage: iterator = (len(l) for i in range(3))
sage: l.extend(iterator)
sage: print(l)
[0, 1, 2]
sage: l = []
sage: iterator = (len(l) for i in range(3))
sage: l[:] = iterator
sage: print(l)
[0, 0, 0]
Le 13/06/2021 à 12:00, 'Martin R' via sage-devel a écrit :
So, my example is fake?
Sébastien Labbé schrieb am Sonntag, 13. Juni 2021 um 08:42:47 UTC+2:
On Thursday, June 10, 2021 at 6:47:37 PM UTC+2 axio...@yahoo.de wrote:
The question is, whether we can rely on behaviour of the reference
implementation of python which contradicts its documentation:
list.extend(*iterable*)
Extend the list by appending all the items from the iterable. Equivalent
to a[len(a):] = iterable.
I believe it is equivalent:
sage: def f(n):
....: return None
....:
sage: l = []; l.extend(f(n) for n in range(3)); l
[None, None, None]
sage: l = []; l[len(l):] = (f(n) for n in range(3));
l
[None, None, None]
Sébastien
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-devel/5d9691b3-7046-392f-fa41-36486adfefdb%40gmail.com.