summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/set_pop.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/set_pop.py')
-rw-r--r--tests/basics/set_pop.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/basics/set_pop.py b/tests/basics/set_pop.py
index 0cd478ce25..5e1196c9f0 100644
--- a/tests/basics/set_pop.py
+++ b/tests/basics/set_pop.py
@@ -7,3 +7,12 @@ except KeyError:
else:
print("Failed to raise KeyError")
+# this tests an optimisation in mp_set_remove_first
+# N must not be equal to one of the values in hash_allocation_sizes
+N = 11
+s = set(range(N))
+while s:
+ print(s.pop()) # last pop() should trigger the optimisation
+for i in range(N):
+ s.add(i) # check that we can add the numbers back to the set
+print(list(s))