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

Function get_random_unicode

python/benchmarks/common.py:94–104  ·  view source on GitHub ↗

Get a random non-ASCII unicode string of size *n*.

(n, seed=42)

Source from the content-addressed store, hash-verified

92
93
94def get_random_unicode(n, seed=42):
95 """
96 Get a random non-ASCII unicode string of size *n*.
97 """
98 indices = np.frombuffer(get_random_bytes(n * 2, seed=seed),
99 dtype=np.int16) & 1023
100 unicode_arr = np.array(_1024_random_unicode_letters)[indices]
101
102 result = ''.join(unicode_arr.tolist())
103 assert len(result) == n, (len(result), len(unicode_arr))
104 return result
105
106
107class BuiltinsGenerator(object):

Callers

nothing calls this directly

Calls 4

get_random_bytesFunction · 0.85
lenFunction · 0.85
arrayMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected