qir-alliance / pyqir

PyQIR is a set of APIs for generating, parsing, and evaluating Quantum Intermediate Representation (QIR).
https://qir-alliance.github.io/pyqir
MIT License
54 stars 24 forks source link

Make enums hashable #236

Closed johngarvin-quantinuum closed 1 year ago

johngarvin-quantinuum commented 1 year ago

For data types that are plain enums, like Opcode, IntPredicate, FloatPredicate, and Linkage, it would be convenient if they were hashable so that they could be used as keys in a dict. For example:

from pyqir import Opcode, IntPredicate  
dict1 = {
    Opcode.ADD: "+",  
    Opcode.SUB: "-",  
  }  
dict2 = {
    IntPredicate.EQ: "==",  
    IntPredicate.NE: "!=",  
  }