question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ParamResolver is hashable but mutable

See original GitHub issue

This 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:closed
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
95-martin-orioncommented, Apr 8, 2022

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.

0reactions
95-martin-orioncommented, Jun 15, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found