Hi, to share data, a number of libraries use the buffer protocol(s)[0 https://docs.python.org/3/c-api/buffer.html]. There seems to be a python issue open [1 https://bugs.python.org/issue27501], and a typing issue open [2 https://github.com/python/typing/issues/593]. Anyone have better interim solution(s) that work cross-library? The given work-around in [2 https://github.com/python/typing/issues/593] doesn't really work in a number of cases:
Union[bytes, bytearray, memoryview]
Consider if this would work with array.array, or
or dozens of other libraries buffer protocol friendly types.
As a concrete example, numpy is adding the ndarray to that Union using this [3 https://github.com/numpy/numpy-stubs/blob/master/numpy-stubs/__init__.pyi#L2... ]: _BufferType = Union[ndarray, bytes, bytearray, memoryview] Whilst this supports ndarray, it doesn't scale to the full list of third party types supporting buffer protocol(s) [opencv, pygame, pillow, ...]. Every suggestion appreciated -- even the strangest, ugliest, most horrific of hacks. Thanks. cheers, [0] https://docs.python.org/3/c-api/buffer.html [1] https://bugs.python.org/issue27501 [2] https://github.com/python/typing/issues/593 [3] https://github.com/numpy/numpy-stubs/blob/master/numpy-stubs/__init__.pyi#L2...