MCPcopy Index your code
hub / github.com/python/cpython / _inverse_lookup

Function _inverse_lookup

Tools/unicode/dawg.py:491–519  ·  view source on GitHub ↗
(packed, pos)

Source from the content-addressed store, hash-verified

489 return _inverse_lookup(packed, pos)
490
491def _inverse_lookup(packed, pos):
492 result = bytearray()
493 node_offset = 0
494 while 1:
495 node_count, final, edge_offset = decode_node(packed, node_offset)
496 if final:
497 if pos == 0:
498 return bytes(result)
499 pos -= 1
500 prev_child_offset = edge_offset
501 edgeindex = 0
502 while 1:
503 child_offset, last_edge, size, edgelabel_chars_offset = decode_edge(packed, edgeindex, prev_child_offset, edge_offset)
504 edgeindex += 1
505 prev_child_offset = child_offset
506 descendant_count, _, _ = decode_node(packed, child_offset)
507 nextpos = pos - descendant_count
508 if nextpos < 0:
509 assert edgelabel_chars_offset >= 0
510 result.extend(packed[edgelabel_chars_offset: edgelabel_chars_offset + size])
511 node_offset = child_offset
512 break
513 elif not last_edge:
514 pos = nextpos
515 edge_offset = edgelabel_chars_offset + size
516 else:
517 raise KeyError
518 else:
519 raise KeyError
520
521
522def build_compression_dawg(ucdata):

Callers 1

inverse_lookupFunction · 0.85

Calls 3

decode_nodeFunction · 0.85
decode_edgeFunction · 0.85
extendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…