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

Function build_compression_dawg

Tools/unicode/dawg.py:522–533  ·  view source on GitHub ↗
(ucdata)

Source from the content-addressed store, hash-verified

520
521
522def build_compression_dawg(ucdata):
523 d = Dawg()
524 ucdata.sort()
525 for name, value in ucdata:
526 d.insert(name, value)
527 packed, pos_to_code, reversedict = d.finish()
528 print("size of dawg [KiB]", round(len(packed) / 1024, 2))
529 # check that lookup and inverse_lookup work correctly on the input data
530 for name, value in ucdata:
531 assert lookup(packed, pos_to_code, name.encode('ascii')) == value
532 assert inverse_lookup(packed, reversedict, value) == name.encode('ascii')
533 return packed, pos_to_code

Callers 2

test_dawgMethod · 0.90
makeunicodenameFunction · 0.90

Calls 7

insertMethod · 0.95
finishMethod · 0.95
DawgClass · 0.85
inverse_lookupFunction · 0.85
lookupFunction · 0.70
sortMethod · 0.45
encodeMethod · 0.45

Tested by 1

test_dawgMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…