Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c6b0f25

Browse files
committed
DOC: add behaviour change note justify this API choice
1 parent a814673 commit c6b0f25

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
AritistList proxies copy contents on iteration
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
When iterating over the contents of the the dynamically generated proxy lists
5+
for the Artist-type accessors (see :ref:`Behavioural API Changes 3.5 - Axes
6+
children combined`), a copy of the contents is made. This ensure that artists
7+
can safely be added or removed from the Axes while iterating over their children.
8+
9+
This is a departure from the expected behavior of mutable iterable data types
10+
in Python -- iterating over list while mutating it has surprising consequences
11+
and dictionaries will error if they change size during iteration. In this case
12+
because all of the accessors are filtered views of the same underlying list, it
13+
is possible for seemingly unrelated changes, such as removing a Line, to affect
14+
the to affect the iteration over any of the other accessors, we have opted to
15+
make a copy of the relevant children before yielding them to the user.
16+
17+
This change is also consistent with our plan to make these accessors immutable
18+
in Matplotlib 3.7.

0 commit comments

Comments
 (0)