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

feat(common): introduce FrozenOrderedDict #9081

Merged
merged 3 commits into from
Apr 30, 2024
Merged

Conversation

kszucs
Copy link
Member

@kszucs kszucs commented Apr 29, 2024

Continuation of #9068 by adding FrozenOrderedDict which calculates its hash from tuple(self.items() rather than frozenset(self.items()) and also checks for item order during equality checks.

Closes #9063.

class FrozenOrderedDict(FrozenDict[K, V]):
def __init__(self, *args, **kwargs):
super(FrozenDict, self).__init__(*args, **kwargs)
hashable = tuple(self.items())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash value is different then FrozenDict's hash which uses frozenset() to calculate the hash.

@kszucs kszucs requested review from cpcloud and gforsyth April 29, 2024 21:50
@cpcloud cpcloud added this to the 9.0 milestone Apr 30, 2024
@cpcloud cpcloud added the feature Features or general enhancements label Apr 30, 2024
@cpcloud
Copy link
Member

cpcloud commented Apr 30, 2024

Clouds are good:

…/ibis on  fod is 📦 v8.0.0 via 🐍 v3.12.2 via ❄️   impure (ibis-3.12.2-env)
❯ pytest -m 'bigquery or snowflake' -n auto --dist loadgroup --snapshot-update
======================================================================================== test session starts =========================================================================================
platform linux -- Python 3.12.2, pytest-8.1.1, pluggy-1.5.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=104835057
rootdir: /home/cloud/src/ibis
configfile: pyproject.toml
plugins: anyio-4.3.0, xdist-3.5.0, pytest_httpserver-1.0.10, cov-5.0.0, timeout-2.3.1, benchmark-4.0.0, randomly-3.15.0, hypothesis-6.100.1, repeat-0.9.3, snapshot-0.9.0, mock-3.14.0, clarity-1.0.1
16 workers [3586 items]
..x.ssssssssssssssssssssssx.......x...........x..x................x........xx..x......x............x...............x....x...........x..........x....x...x...........x..............x...x...... [  5%]
........x...........................x.....x..x.........xx...x........x......x......x........x......x......x....x.............xx.................xxxxxxx.xxxx...x.....x..x.x.x................. [ 10%]
..xx........x......x......x....x.......x...x...........x.......................................x.........................................x.................................................... [ 15%]
..........x.............................xxx..s...............s.s..........................................s..........................x........x.x..........sx...x..x................s.s....... [ 21%]
..x..s.xx..x.....x..x..x.................x.xx....x.....x....x.x.....x.......xx.....x.......x..........x......x...x.xx.x........x...........x.................x..xx....x..x.................x.. [ 26%]
.x..xx..x.x..xx...x..xxx.xx.xx.....xx.....xxx.x...xxx.....x.x.........x........xx.x......................x.x...xx...x......x.x..x..x..x........................xx......xx...........x.....x... [ 31%]
x......x.xxxxxx.xxxx.x..x...xx.....x.x...x....xxxx..x...xxxx........x...x.......x.xx...xxx.....x.......xx...x........x..x.xx.........x...x.....x.x.........................x......x.....xx.... [ 37%]
.xx........x....................xx.xx.......xxxxxxx..x.x.xxxxxx.xxxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...x...xx..x...x........ [ 42%]
..x...x....x..x...x................................x......x..........................x..x........x......................x...........x.xx....x.........x..........x............x.....x......x... [ 47%]
......................x......xx.........x..................................................xx...xxxxxxxxx.x...xx..x..xxx...x.....x...x..x..................x...x......x..........x....x.x..x.. [ 53%]
.xx........x..................x.x.x...x........x....x.....x..x.............................x.......x..xxx..................x..........x..................x.............sx.....x.......x....... [ 58%]
........x............................................................s......................s....x..x.s...x......x.........x...s.x...x..............x.......x.............x......x............. [ 63%]
x....xx....xx.................x........x...xx.......x........xx.....x.....x.x........x...x.x............x.....................xx...x.......x...............x......x.x....x.................... [ 68%]
....x....x............x..................................................x..x.x..x..x..............x.....x........x...............x..x........xx...xx.xxx.xxxxxx.xx.x.................x.x....x [ 74%]
.........................xx.......x.........................xx.x.......x......x.x.........x.......x.........x.....x.....xx.............x..x.........x.x.xs..x..........................x..x... [ 79%]
...xxx.xxxx...xxx...x.x....x......xx........xxx.xx..xx....xxxxxxxx...xx.xxxxx.xxx.xxx........x.xxx.x...x.xx.xxxx.xx.x........x...........xx..x..............................x.x..x............ [ 84%]
...........................................................s..........s....................................................................................................................... [ 90%]
.............................................................................................................................................................................................. [ 95%]
.......................................................................................................x....s.........................xx.........................x..                           [100%]
===================================================================== 2978 passed, 39 skipped, 569 xfailed in 485.86s (0:08:05) ======================================================================

@cpcloud cpcloud merged commit f926995 into ibis-project:main Apr 30, 2024
86 checks passed
@cpcloud cpcloud deleted the fod branch April 30, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: .cache() gives incorrect result when column order changes
2 participants