Skip to content

Commit 77a62d8

Browse files
committed
tests/stress: Add test to create a dict beyond "maximum" rehash size.
There is a finite list of ascending primes used for the size of a hash table, and this test tests that the code can handle a dict larger than the maximum value in that list of primes. Adding this tests gets py/map.c to 100% coverage.
1 parent 90da791 commit 77a62d8

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

tests/stress/dict_create_max.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# The aim with this test is to hit the maximum resize/rehash size of a dict,
2+
# where there are no more primes in the table of growing allocation sizes.
3+
# This value is 54907 items.
4+
5+
d = {}
6+
try:
7+
for i in range(54908):
8+
d[i] = i
9+
except MemoryError:
10+
pass
11+
12+
# Just check the dict still has the first value
13+
print(d[0])

0 commit comments

Comments
 (0)