Skip to content

Commit 33223d1

Browse files
committed
Change iter fn
1 parent d665b16 commit 33223d1

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/sage/interfaces/maxima_abstract.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,17 +1689,6 @@ def __getitem__(self, i):
16891689
# If you change the i+1 to i below, better change __iter__ as well.
16901690
return InterfaceElement.__getitem__(self, i+1)
16911691

1692-
def __iter_without_mutation(self):
1693-
"""
1694-
Returns an iterator for ``self``. It is assumed that ``self`` won't be
1695-
mutated during the iteration.
1696-
"""
1697-
N = len(self)
1698-
z = self
1699-
for _ in range(N):
1700-
yield z.first()
1701-
z = z.rest()
1702-
17031692
def __iter__(self):
17041693
"""
17051694
Return an iterator for ``self``.
@@ -1713,8 +1702,9 @@ def __iter__(self):
17131702
sage: [e._sage_() for e in L]
17141703
[0, x, 2*x^2, 3*x^3, 4*x^4, 5*x^5]
17151704
"""
1716-
# NOTE: `self` should not be mutated during iteration
1717-
return self.__iter_without_mutation()
1705+
z = self.copy()
1706+
for _ in range(len(z)):
1707+
yield z.pop()
17181708

17191709
def subst(self, val):
17201710
"""

0 commit comments

Comments
 (0)