Estoy recibiendo el mensaje de advertencia al intentar utilizar una matriz como una matriz ctypes numpy:PEP 3118 advertencia al utilizar ctypes matriz como matriz numpy
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes, numpy
>>> TenByteBuffer = ctypes.c_ubyte * 10
>>> a = TenByteBuffer()
>>> b = numpy.ctypeslib.as_array(a)
C:\Python27\lib\site-packages\numpy\ctypeslib.py:402: RuntimeWarning: Item size
computed from the PEP 3118 buffer format string does not match the actual item s
ize.
return array(obj, copy=False)
>>> b
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=uint8)
El código parece estar funcionando, sin embargo. ¿Es una mala idea ignorar esta advertencia?
Antecedentes: Estoy llamando a una DLL de C que produce datos en tiempo real. Necesito pasar la DLL una serie de almacenamientos intermedios para contener los datos. Mientras espero a que se llene el siguiente buffer, me gustaría procesar el buffer más reciente con numpy y guardar el resultado. Estoy generando los buffers con el código anterior, y las cosas parecen estar funcionando, pero no quiero barrer un problema importante debajo de la alfombra.
Curiosamente, esto no parece suceder con python2.6, solo python2.7 ... –