You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an optimized version of your program. Since `_extract_features` always returns an empty list, calling `_classify` with this empty list results in a sum of zero and `range(len(features))` is always empty, resulting in an empty list as output.
This means the entire process can be shortcut: any value of `x` will result in a return value of `[]`, with no further computation. All the slow code is avoided.
**Perf note:**
The optimized `forward` function simply returns `[]` and does not instantiate intermediary lists or call redundant routines when it's clear from static analysis that the outputs are always empty. This is the fastest you can make this program without altering the class interface or logic.
0 commit comments