Calling unittest.assertDictEqual for medium-size dictionaries takes too long
Open
Nobody has claimed this yet.
stdlib
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Calling assertDictEqual(d1, d2) / takes forever, even for medium-size dictionaries. To reproduce:
from unittest import TestCase
from random import randint
def test_assert_dict(self):
r = 10000000
num = 10000
d1 = dict((randint(0, r), randint(0, r)) for _ in range(num))
d2 = dict((randint(0, r), randint(0, r)) for _ in range(num))
self.assertDictEqual(d1, d2)
Probably related to issue #63416.
Tested on Python 3.10, Windows 11
Linked PRs
- gh-126923
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Python reproduction and inspect unittest.assertDictEqual, then read issue #63416 and linked PR gh-126923 for existing context. Done means the medium-size dictionary comparison no longer takes an excessive amount of time, with the behavior checked against the reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100