summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/set_pop.py
blob: e951ca5931f2ab4b074d1f49b3044d902536b101 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
s = {1}
print(s.pop())
try:
    print(s.pop(), "!!!")
except KeyError:
    pass
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(sorted(s))