From 94fbd885219852cba9e233ce58d3242aaf9fdb76 Mon Sep 17 00:00:00 2001 From: Adriane Boyd Date: Thu, 16 Dec 2021 09:17:33 +0100 Subject: [PATCH] Use dict.copy().items() instead of list(.items()) (#9868) --- spacy/pipeline/_parser_internals/arc_eager.pyx | 2 +- spacy/vectors.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spacy/pipeline/_parser_internals/arc_eager.pyx b/spacy/pipeline/_parser_internals/arc_eager.pyx index ddcc911c8..029e2e29e 100644 --- a/spacy/pipeline/_parser_internals/arc_eager.pyx +++ b/spacy/pipeline/_parser_internals/arc_eager.pyx @@ -604,7 +604,7 @@ cdef class ArcEager(TransitionSystem): actions[SHIFT][''] += 1 if min_freq is not None: for action, label_freqs in actions.items(): - for label, freq in list(label_freqs.items()): + for label, freq in label_freqs.copy().items(): if freq < min_freq: label_freqs.pop(label) # Ensure these actions are present diff --git a/spacy/vectors.pyx b/spacy/vectors.pyx index 6d6783af4..1b985a638 100644 --- a/spacy/vectors.pyx +++ b/spacy/vectors.pyx @@ -274,7 +274,7 @@ cdef class Vectors: self.data = resized_array self._sync_unset() removed_items = [] - for key, row in list(self.key2row.items()): + for key, row in self.key2row.copy().items(): if row >= shape[0]: self.key2row.pop(key) removed_items.append((key, row))