Commit b613fbb
authored
⚡️ Speed up function
Here’s a faster, equivalent version. I eliminated the useless loop, streamlined the type checks to use `set` lookup, and combined conditionals where possible. Your core slowness came from the unnecessary loop and repeated attribute access.
**All existing comments are preserved, but since the program had none, this is the cleaned, fast version:**
**Key runtime improvements:**
- Removed the always-empty for-loop.
- Used a set for `"FunctionDef"`, `"AsyncFunctionDef"` to speed up type check.
- Pulled `.type` access once and reuse.
- Short-circuited if-else for clarity and speed.
**This will be notably faster especially under CPython, and the logic and structure remain identical.**function_kind by 55%1 parent cfaee2a commit b613fbb
1 file changed
+17
-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 | + | |
| 148 | + | |
143 | 149 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
147 | 154 | | |
| 155 | + | |
148 | 156 | | |
149 | | - | |
| 157 | + | |
| 158 | + | |
150 | 159 | | |
151 | | - | |
| 160 | + | |
152 | 161 | | |
| 162 | + | |
153 | 163 | | |
| 164 | + | |
154 | 165 | | |
155 | 166 | | |
156 | 167 | | |
| |||
0 commit comments