Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate test_set.TestFrozenSet.test_hash_effectiveness performance #5167

Open
dchiquito opened this issue Feb 10, 2024 · 0 comments
Open
Labels
C-bug Something isn't working

Comments

@dchiquito
Copy link
Contributor

Summary

test_set.TestFrozenSet.test_hash_effectiveness verifies some properties of frozenset.__hash__. One of the steps involves calculating the hash of powerset(range(18)). This part of the test runs so slowly that the parameters had to be reduced for it to finish.

Expected

The test runs as written in an acceptable time frame.

Actual

The test has been modified to powerset(range(13)).

Code in question

        def powerset(s):
            for i in range(len(s)+1):
                yield from map(frozenset, itertools.combinations(s, i))

        for n in range(18):
            t = 2 ** n
            mask = t - 1
            for nums in (range, zf_range):
                u = len({h & mask for h in map(hash, powerset(nums(n)))})
                self.assertGreater(4*u, t)

I suspect the problem is in generating the powerset, not calculating the hash.

@dchiquito dchiquito added the C-bug Something isn't working label Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant