Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c4c169c commit ba58718Copy full SHA for ba58718
1 file changed
numpy/core/tests/test_unicode.py
@@ -5,7 +5,19 @@
5
from numpy.compat import asbytes
6
7
# Guess the UCS length for this python interpreter
8
-if sys.version_info[0] >= 3:
+if sys.version_info[:2] >= (3, 3):
9
+ # Python 3.3 uses a flexible string representation
10
+ ucs4 = False
11
+ def buffer_length(arr):
12
+ if isinstance(arr, unicode):
13
+ arr = str(arr)
14
+ return (sys.getsizeof(arr+"a") - sys.getsizeof(arr)) * len(arr)
15
+ v = memoryview(arr)
16
+ if v.shape is None:
17
+ return len(v) * v.itemsize
18
+ else:
19
+ return prod(v.shape) * v.itemsize
20
+elif sys.version_info[0] >= 3:
21
import array as _array
22
ucs4 = (_array.array('u').itemsize == 4)
23
def buffer_length(arr):
0 commit comments