summaryrefslogtreecommitdiff
path: root/numpy/array_api/tests/test_array_object.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-12-15 16:58:34 -0600
committerSebastian Berg <sebastian@sipsolutions.net>2021-12-15 17:01:10 -0600
commit6c5a9ac9681dba754728d40e3d2ea0fe4c10abcc (patch)
treef03fc828eeb2238f09f2527f54c982f62029c491 /numpy/array_api/tests/test_array_object.py
parent43c113dd7aa36ef833315035858ea98a7b4732c5 (diff)
downloadnumpy-6c5a9ac9681dba754728d40e3d2ea0fe4c10abcc.tar.gz
MAINT: Check for buffer interface support rather than try/except
This checks for buffer interface support using `PyObject_CheckBuffer` up-front. That seems to shave off about 100ns e.g. when importing pandas DataFrames (which do not support the buffer interface, but do support `__array__`. The reason is that building a TypeError and then clearing it takes time. It felt like a clear, easy win, since the check should be so fast that checking twice (in the case that it is indeed a buffer) does not really matter. But, if nobody likes to think about it just close :).
Diffstat (limited to 'numpy/array_api/tests/test_array_object.py')
0 files changed, 0 insertions, 0 deletions