Commit b5673bf
authored
Here is an optimized version of your program with reduced code execution overhead, memory allocation, and efficient logic. All return values remain exactly the same, and function signatures are unchanged. Comments are preserved as required.
**Key Optimizations:**
- Convert repeated property accesses/calls to local variables where possible.
- Reuse the same decorator AST node object where safe (AST is not mutated elsewhere).
- Pre-check presence of target class and short-circuit early.
- In the loop, short-circuit when `__init__` is found to avoid unnecessary iterations.
**Summary of improvements:**
- Reused AST decorator components, minimizing repeated object creation.
- Early exit on target class and `__init__` findings.
- Less variable assignment and number of iterations.
- All core logic and comments are preserved.
1 parent 586f5af commit b5673bf
1 file changed
+32
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
| |||
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
117 | | - | |
118 | 129 | | |
| 130 | + | |
119 | 131 | | |
120 | | - | |
| 132 | + | |
121 | 133 | | |
122 | | - | |
| 134 | + | |
123 | 135 | | |
124 | 136 | | |
125 | 137 | | |
126 | | - | |
127 | | - | |
128 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
129 | 141 | | |
130 | 142 | | |
131 | 143 | | |
| 144 | + | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
| |||
138 | 151 | | |
139 | 152 | | |
140 | 153 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
151 | 167 | | |
152 | 168 | | |
153 | 169 | | |
| |||
0 commit comments