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 TensorChunker._split_value by 12% in PR #272 (14__robusttraining)
Sure, I can make the given code more efficient. Here are the main improvements.
1. Simplify the chunk splitting and dummy chunk creation to use fewer operations.
2. Avoid repetitive appending in a loop by pre-determining the length and constructing the final list accordingly.
Here is the optimized version of the provided code.
Improvements made.
1. Instead of using a conditional and loop to append dummy chunks, I pre-determine the number of necessary dummy chunks and extend the list in one operation.
2. Created the `dummy_chunk_flags` list in one go, thus avoiding repeated appending operations.
With these changes, the function should run faster while maintaining the intended behavior.
0 commit comments