Conversation
cc66ec4 to
27614a7
Compare
2ee3887 to
1924c28
Compare
src/instana/util/span_utils.py
Outdated
| remaining = key_parts[i:] | ||
| if not remaining: | ||
| return data[candidate] | ||
| result = resolve_nested_key(data[candidate], remaining) |
There was a problem hiding this comment.
I suggest that you refactor this function to use a while loop instead of a recursive function - a while loop is usually faster with constant memory usage than recursion in Python because Python is optimized for iteration, not recursion.
Every recursive call in Python pushes a new frame onto the call stack — local variables, argument bindings, return address, etc. For a deeply nested structure (say, 50 key parts), that's 50 frames allocated and deallocated. The iterative version reuses a single frame throughout. This is relatively costly in Python.
There was a problem hiding this comment.
Done, please review
Signed-off-by: Cagri Yonca <cagri@ibm.com>
1924c28 to
d256e9f
Compare
|



No description provided.