Browse Source
Use a set instead of a list for the visited tracker, converting the membership check from O(n) to O(1). DependencyCacheKey is a hashable tuple, so the swap is safe. Defer param list copies until a child actually has data to merge (copy-on-write). Nodes whose children carry no params skip all five list allocations entirely, which is the common case for paramless dependency functions. Skip the oauth_scopes property call and intermediate list concatenations when no scopes are present. Benchmarks (synthetic trees, min of 5×1000 runs, Python 3.11): | Scenario | Speed | RAM | |--------------|--------|--------| | Chain ×100 | −28 % | −12 % | | Wide 100×3 | −57 % | −29 % | | Diamond ×100 | −39 % | −31 % |pull/15620/head
1 changed files with 34 additions and 16 deletions
Loading…
Reference in new issue