55from types import FrameType
66from typing import Any , List
77
8+ from cg_trace .utils import better_compare_for_dataclass
9+
810LOGGER = logging .getLogger (__name__ )
911
1012# See https://docs.python.org/3/library/dis.html#python-bytecode-instructions for
@@ -18,6 +20,7 @@ class BytecodeExpr:
1820 """
1921
2022
23+ @better_compare_for_dataclass
2124@dataclasses .dataclass (frozen = True , eq = True , order = True )
2225class BytecodeConst (BytecodeExpr ):
2326 """FOR LOAD_CONST"""
@@ -28,6 +31,7 @@ def __str__(self):
2831 return repr (self .value )
2932
3033
34+ @better_compare_for_dataclass
3135@dataclasses .dataclass (frozen = True , eq = True , order = True )
3236class BytecodeVariableName (BytecodeExpr ):
3337 name : str
@@ -36,6 +40,7 @@ def __str__(self):
3640 return self .name
3741
3842
43+ @better_compare_for_dataclass
3944@dataclasses .dataclass (frozen = True , eq = True , order = True )
4045class BytecodeAttribute (BytecodeExpr ):
4146 attr_name : str
@@ -45,6 +50,7 @@ def __str__(self):
4550 return f"{ self .object } .{ self .attr_name } "
4651
4752
53+ @better_compare_for_dataclass
4854@dataclasses .dataclass (frozen = True , eq = True , order = True )
4955class BytecodeSubscript (BytecodeExpr ):
5056 key : BytecodeExpr
@@ -54,6 +60,7 @@ def __str__(self):
5460 return f"{ self .object } [{ self .key } ]"
5561
5662
63+ @better_compare_for_dataclass
5764@dataclasses .dataclass (frozen = True , eq = True , order = True )
5865class BytecodeTuple (BytecodeExpr ):
5966 elements : List [BytecodeExpr ]
@@ -67,6 +74,7 @@ def __str__(self):
6774 return f"({ elements_formatted } )"
6875
6976
77+ @better_compare_for_dataclass
7078@dataclasses .dataclass (frozen = True , eq = True , order = True )
7179class BytecodeList (BytecodeExpr ):
7280 elements : List [BytecodeExpr ]
@@ -80,6 +88,7 @@ def __str__(self):
8088 return f"[{ elements_formatted } ]"
8189
8290
91+ @better_compare_for_dataclass
8392@dataclasses .dataclass (frozen = True , eq = True , order = True )
8493class BytecodeCall (BytecodeExpr ):
8594 function : BytecodeExpr
@@ -88,6 +97,7 @@ def __str__(self):
8897 return f"{ self .function } ()"
8998
9099
100+ @better_compare_for_dataclass
91101@dataclasses .dataclass (frozen = True , eq = True , order = True )
92102class BytecodeUnknown (BytecodeExpr ):
93103 opname : str
@@ -96,6 +106,7 @@ def __str__(self):
96106 return f"<{ self .opname } >"
97107
98108
109+ @better_compare_for_dataclass
99110@dataclasses .dataclass (frozen = True , eq = True , order = True )
100111class BytecodeMakeFunction (BytecodeExpr ):
101112 """For MAKE_FUNCTION opcode"""
@@ -106,6 +117,7 @@ def __str__(self):
106117 return f"<MAKE_FUNCTION>(qualified_name={ self .qualified_name } )>"
107118
108119
120+ @better_compare_for_dataclass
109121@dataclasses .dataclass (frozen = True , eq = True , order = True )
110122class SomethingInvolvingScaryBytecodeJump (BytecodeExpr ):
111123 opname : str
0 commit comments