ParamResolver is hashable but mutable
See original GitHub issueThis is bad!
pdict = {'beta': 0.11, 'gamma': 0.3}
pdict
Out[11]: {'beta': 0.11, 'gamma': 0.3}
p = cirq.ParamResolver(pdict)
p
Out[13]: cirq.ParamResolver({'beta': 0.11, 'gamma': 0.3})
hash(p)
Out[14]: 9055359463938249742
pdict['beta'] = 5
p
Out[16]: cirq.ParamResolver({'beta': 5, 'gamma': 0.3})
hash(p)
Out[17]: 9055359463938249742
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Hashable, immutable - python - Stack Overflow
Are there mutable objects that are hashable or immutable objects that are not hashable? In Python, tuple is immutable, but it is hashable...
Read more >Immutable vs. Hashable - Real Python
00:23 All immutable objects are hashable, but not all hashable objects are ... objects are hashable and they can include mutable objects that...
Read more >Hashable Objects Must Be Immutable - Invent with Python
A recent post to Reddit sparked some comments, so I wanted to clarify: In Python, hashable objects must be immutable and mutable objects...
Read more >cirq.TaggedOperation - Google Quantum AI
A function or a dict mapping each current qubit into a desired new qubit. Returns. The receiving operation but with qubits transformed by ......
Read more >ClipData.java - Android Code Search
representation (but not for "content", "android.resource" or "file" schemes). ... @param resolver ContentResolver used to get information about the URI.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is already documented: https://github.com/quantumlib/Cirq/blob/f1ea0bd78ce3b287ca925c2306919134650c2607/cirq-core/cirq/study/resolver.py#L53 I’m loath to introduce performance reductions to ParamResolver specifically as it’s part of the cirq-to-qsim translation hot path, which we’re actively trying to speed up.
Lessons from un-hashing experiment: more pain than it’s worth, likely introduces new and exciting issues.
The chosen resolution for this at the Cirq sync is outlined in #5507: we’ll make the relevant fields “private” and use properties to at least let mypy identify sketchy behavior.