MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _walk_python_tree

Function _walk_python_tree

graphify/extractors/resolution.py:3416–3429  ·  view source on GitHub ↗

Preorder walk of a tree-sitter tree, iteratively. The recursive ``yield from`` form built one suspended generator frame per ancestor and re-propagated every node up the whole chain — ~25M frame resumptions on a 364-file corpus for ~2.8M actual nodes. An explicit stack yields each no

(node)

Source from the content-addressed store, hash-verified

3414 return None
3415
3416def _walk_python_tree(node):
3417 """Preorder walk of a tree-sitter tree, iteratively.
3418
3419 The recursive ``yield from`` form built one suspended generator frame per
3420 ancestor and re-propagated every node up the whole chain — ~25M frame
3421 resumptions on a 364-file corpus for ~2.8M actual nodes. An explicit stack
3422 yields each node exactly once in the identical preorder (children pushed
3423 reversed so the first child pops first).
3424 """
3425 stack = [node]
3426 while stack:
3427 current = stack.pop()
3428 yield current
3429 stack.extend(reversed(current.children))
3430
3431def _python_import_from_module(node, source: bytes) -> tuple[int, str] | None:
3432 level = 0

Calls

no outgoing calls