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

Function generate_generalized_integer

Lib/encodings/punycode.py:78–89  ·  view source on GitHub ↗

3.3 Generalized variable-length integers

(N, bias)

Source from the content-addressed store, hash-verified

76
77digits = b"abcdefghijklmnopqrstuvwxyz0123456789"
78def generate_generalized_integer(N, bias):
79 """3.3 Generalized variable-length integers"""
80 result = bytearray()
81 j = 0
82 while 1:
83 t = T(j, bias)
84 if N < t:
85 result.append(digits[N])
86 return result.take_bytes()
87 result.append(digits[t + ((N - t) % (36 - t))])
88 N = (N - t) // (36 - t)
89 j += 1
90
91def adapt(delta, first, numchars):
92 if first:

Callers 1

generate_integersFunction · 0.85

Calls 3

take_bytesMethod · 0.80
TFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…