Search code examples
pythonpypypython-cffi

How to get type of cdata of pypy cffi?


>>>> a = ffi.cast('int', 10)            
>>>> <cdata 'int' 10>

I want to know the type of the value of 'a'. I've typed 'dir(a)' kind of things, but I cannot find any method to do it. I want a function like below

>>>> gettypeofcdata(a)
>>>> 'int'

But I'm not sure if pypy's cffi has this kind of function. Does anyone know about this?


Solution

  • You are looking for ffi.typeof(cdata). You have further attributes on the CType object that you get, if needed.