MCPcopy Create free account
hub / github.com/apache/arrow / _random_unicode_letters

Function _random_unicode_letters

python/benchmarks/common.py:70–88  ·  view source on GitHub ↗

Generate a string of random unicode letters (slow).

(n, seed=42)

Source from the content-addressed store, hash-verified

68
69
70def _random_unicode_letters(n, seed=42):
71 """
72 Generate a string of random unicode letters (slow).
73 """
74 def _get_more_candidates():
75 return rnd.randint(0, sys.maxunicode, size=n).tolist()
76
77 rnd = np.random.RandomState(seed)
78 out = []
79 candidates = []
80
81 while len(out) < n:
82 if not candidates:
83 candidates = _get_more_candidates()
84 ch = chr(candidates.pop())
85 # XXX Do we actually care that the code points are valid?
86 if unicodedata.category(ch)[0] == 'L':
87 out.append(ch)
88 return out
89
90
91_1024_random_unicode_letters = _random_unicode_letters(1024)

Callers 1

common.pyFile · 0.85

Calls 3

lenFunction · 0.85
_get_more_candidatesFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected