forked from Rust-related/RustPython
Cache hash value for FrozenSets
Adds a hash field to the `PyFrozenSet` data type in order to avoid recomputing the hash of an immutable object.
This commit is contained in:
10
Lib/test/test_set.py
vendored
10
Lib/test/test_set.py
vendored
@@ -728,15 +728,7 @@ class TestFrozenSet(TestJointOps, unittest.TestCase):
|
||||
for i in range(len(s)+1):
|
||||
yield from map(frozenset, itertools.combinations(s, i))
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
# The original test has:
|
||||
# for n in range(18):
|
||||
# Due to general performance overhead, hashing a frozenset takes
|
||||
# about 50 times longer than in CPython. This test amplifies that
|
||||
# exponentially, so the best we can do here reasonably is 13.
|
||||
# Even if the internal hash function did nothing, it would still be
|
||||
# about 40 times slower than CPython.
|
||||
for n in range(13):
|
||||
for n in range(18):
|
||||
t = 2 ** n
|
||||
mask = t - 1
|
||||
for nums in (range, zf_range):
|
||||
|
||||
Reference in New Issue
Block a user