MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / count_cache_key_tuples

Function count_cache_key_tuples

lib/sqlalchemy/testing/util.py:541–560  ·  view source on GitHub ↗

given a cache key tuple, counts how many instances of actual tuples are found. used to alert large jumps in cache key complexity.

(tup)

Source from the content-addressed store, hash-verified

539
540
541def count_cache_key_tuples(tup):
542 """given a cache key tuple, counts how many instances of actual
543 tuples are found.
544
545 used to alert large jumps in cache key complexity.
546
547 """
548 stack = [tup]
549
550 sentinel = object()
551 num_elements = 0
552
553 while stack:
554 elem = stack.pop(0)
555 if elem is sentinel:
556 num_elements += 1
557 elif isinstance(elem, tuple):
558 if elem:
559 stack = list(elem) + [sentinel] + stack
560 return num_elements
561
562
563@contextlib.contextmanager

Callers 1

test_cache_key_genMethod · 0.90

Calls 1

popMethod · 0.45

Tested by 1

test_cache_key_genMethod · 0.72