pcpfast.py 文件源码

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

项目:supremm 作者: ubccr 项目源码 文件源码
def pcpfastExtractValues(result_p, vsetidx, vlistidx, dtype):
    """ quicker implementation of pmExtractValue than the default provided with the pcp python bindings
        this version saves converting the C indexes to python and back again
    """

    inst = c_int()
    outAtom = pmapi.pmAtomValue()
    status = LIBPCPFAST.pcpfastExtractValues(result_p, byref(inst), byref(outAtom), vsetidx, vlistidx, dtype)
    if status < 0:
        raise pmapi.pmErr(status)

    if dtype == c_api.PM_TYPE_STRING:
        # Get pointer to C string
        c_str = c_char_p()
        memmove(byref(c_str), addressof(outAtom) + pmapi.pmAtomValue.cp.offset, sizeof(c_char_p))
        # Convert to a python string and have result point to it
        outAtom.cp = outAtom.cp
        # Free the C string
        LIBC.free(c_str)

    return outAtom.dref(dtype), inst.value
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号