interop.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:zanph 作者: zanph 项目源码 文件源码
def cast_int_addr(n):
    """Cast an address to a Python int

    This could be a Python integer or a CFFI pointer
    """
    if isinstance(n, (int, long)):
        return n
    try:
        import cffi
    except ImportError:
        pass
    else:
        # from pyzmq, this is an FFI void *
        ffi = cffi.FFI()
        if isinstance(n, ffi.CData):
            return int(ffi.cast("size_t", n))

    raise ValueError("Cannot cast %r to int" % n)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号