Is your feature request related to a problem? Please describe.
Yes, I'm frustrated by redundant CPU operations running inside tight loops. Inside get_entity_context, the variable assignment left = _node_name(graph, node_id) is currently located deep inside the for neighbor_id in neighbors: loop block. Because the node_id value stays completely constant for the entire duration of its neighbors' loop execution, evaluating its string name over and over is entirely redundant. If a node has 50 neighbors, the string retrieval functions execute 50 times instead of once.
Describe the solution you'd like
I want to hoist the statement left = _node_name(graph, node_id) up by exactly one block level. It should sit directly underneath the outer for node_id in matched_nodes: block but above the inner neighbor iteration loop. This will cache the string value once per matched node, saving significant CPU cycles when handling dense, highly-connected query graphs.
Describe alternatives you've considered
No response
Additional Context
No response
GSSoC '26
Is your feature request related to a problem? Please describe.
Yes, I'm frustrated by redundant CPU operations running inside tight loops. Inside get_entity_context, the variable assignment left = _node_name(graph, node_id) is currently located deep inside the for neighbor_id in neighbors: loop block. Because the node_id value stays completely constant for the entire duration of its neighbors' loop execution, evaluating its string name over and over is entirely redundant. If a node has 50 neighbors, the string retrieval functions execute 50 times instead of once.
Describe the solution you'd like
I want to hoist the statement left = _node_name(graph, node_id) up by exactly one block level. It should sit directly underneath the outer for node_id in matched_nodes: block but above the inner neighbor iteration loop. This will cache the string value once per matched node, saving significant CPU cycles when handling dense, highly-connected query graphs.
Describe alternatives you've considered
No response
Additional Context
No response
GSSoC '26