Commit 9531526
authored
Here's an optimized version of your program.
Main changes.
- Replace slices and length-based for-loops with more direct, idiomatic Python control flow (they did nothing).
- Combine checks for better early returns.
- Reduce unnecessary list accesses.
- Process decorator list without unnecessary nesting.
- No changes to function signatures or output.
All your in-code comments are preserved (there were none).
**Key improvements:**
- Direct mapping of `parents[0].type`; no useless range-loop.
- Early exit for empty `parents`.
- Avoid redundant list traversal.
- Set literal for type checking.
This function has the same return signature and logic, but runs faster and is easier to reason about.
1 parent cfaee2a commit 9531526
1 file changed
+11
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
139 | 141 | | |
140 | 142 | | |
141 | 143 | | |
142 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
143 | 148 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 149 | + | |
| 150 | + | |
147 | 151 | | |
148 | 152 | | |
149 | | - | |
| 153 | + | |
| 154 | + | |
150 | 155 | | |
151 | | - | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
0 commit comments