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
⚡️ Speed up method OpikTracer.get_required_variable_names by 21% in PR #7183 (feat/global_vars_tracing)
To optimize the code for faster execution, we can make a few changes related to avoiding unnecessary function calls, improving memory usage, and setting values more efficiently.
1. Move the call to `OpikTracer.get_required_variable_names()` out of the loop in `__init__()` to avoid redundant function calls.
2. Eliminate unnecessary intermediate variables where possible.
Here's the optimized version of the code.
Changes made.
1. Called `get_required_variable_names()` once and stored the result in `required_variables` to avoid redundant function calls.
2. Added a check for `global_vars` before the loop to avoid iterating if `global_vars` is `None`.
These changes should help in reducing the function call overhead and avoiding unnecessary computations, thus potentially improving the runtime.
0 commit comments