diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_internal.py | 24 | ||||
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 7 |
2 files changed, 7 insertions, 24 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 7b8ab9215..1cd6cd17f 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -247,30 +247,6 @@ class _missing_ctypes(object): self.value = ptr -class _unsafe_first_element_pointer(object): - """ - Helper to allow viewing an array as a ctypes pointer to the first element - - This avoids: - * dealing with strides - * `.view` rejecting object-containing arrays - * `memoryview` not supporting overlapping fields - """ - def __init__(self, arr): - self.base = arr - - @property - def __array_interface__(self): - i = dict( - shape=(), - typestr='|V0', - data=(self.base.__array_interface__['data'][0], False), - strides=(), - version=3, - ) - return i - - class _ctypes(object): def __init__(self, array, ptr=None): self._arr = array diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index b0623bd86..06a1a0a3d 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -7938,6 +7938,8 @@ class TestFormat(object): dst = object.__format__(a, '30') assert_equal(res, dst) +from numpy.testing import IS_PYPY + class TestCTypes(object): def test_ctypes_is_available(self): @@ -8020,6 +8022,11 @@ class TestCTypes(object): # but when the `ctypes_ptr` object dies, so should `arr` del ctypes_ptr + if IS_PYPY: + # Pypy does not recycle arr objects immediately. Trigger gc to + # release arr. Cpython uses refcounts. An explicit call to gc + # should not be needed here. + break_cycles() assert_(arr_ref() is None, "unknowable whether ctypes pointer holds a reference") |