MCPcopy Index your code
hub / github.com/numpy/numpy / buffer_length

Function buffer_length

numpy/_core/tests/test_unicode.py:6–23  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

4
5
6def buffer_length(arr):
7 if isinstance(arr, str):
8 if not arr:
9 charmax = 0
10 else:
11 charmax = max(ord(c) for c in arr)
12 if charmax < 256:
13 size = 1
14 elif charmax < 65536:
15 size = 2
16 else:
17 size = 4
18 return size * len(arr)
19 v = memoryview(arr)
20 if v.shape is None:
21 return len(v) * v.itemsize
22 else:
23 return np.prod(v.shape) * v.itemsize
24
25
26# In both cases below we need to make sure that the byte swapped value (as

Callers 3

content_checkMethod · 0.85
content_checkMethod · 0.85
content_checkMethod · 0.85

Calls 2

maxFunction · 0.50
prodMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…