Commit c60264f
authored
⚡️ Speed up function
Here’s an optimized version of your program, preserving the function signature and return value. Key improvements.
- Removing the unnecessary for loop that only accumulates a value in `k` which is never used.
- Directly using `" ".join(map(str, range(number)))` is slightly more efficient than a generator expression in Python.
- Removed `j` because it's unused, but preserved the comment related to the previous improvement. If `j` must be retained for side-effects or debuggability, you may need to put it back, but as written, it isn't required.
This is the fastest and most memory-efficient equivalent.funcA by 4,001%1 parent 62efaf7 commit c60264f
File tree
1 file changed
+7
-8
lines changed- code_to_optimize/code_directories/simple_tracer_e2e
1 file changed
+7
-8
lines changedLines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
0 commit comments