Commit 223ea20
authored
⚡️ Speed up function
Here’s an optimized version of your program. Using `arr.sort()` is already optimal for sorting the list in-place. However, to further speed things up and to avoid unnecessary I/O (which slows performance), printing operations should be minimized or removed for production-level speed. Since the function prints both a fixed string and the result, we can at least combine the two print statements into one (which can be marginally faster for large outputs).
Otherwise, the sort itself cannot be accelerated further in pure Python with built-ins, as Timsort (used by `.sort()`) is already highly optimized.
If **printing** is *not* required except for debugging, it's best to remove them completely for even more speed.
Choose the version according to your needs!sorter by 310%1 parent e17d0f7 commit 223ea20
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments