ctypes dll加载非常

2024-07-04 08:43:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用ctypes加载一个dll来控制一个测量计算小型实验室板。它可以工作,但需要大约5秒来加载。在

有没有办法让这个更快?在

这个库包含大约100个函数,我只使用其中一个。我可以告诉ctypes只加载那个函数或类似的东西吗?在

import ctypes

class DaqInterface(object):
    def __init__(self):
        self.dll = ctypes.WinDLL("cbw64.dll")

    def set_analog(self, data, channel=0, board_num=0):
        res = self.dll.cbAOut(ctypes.c_int(board_num), ctypes.c_int(channel), ctypes.c_int(0), ctypes.c_int(data))
        if res != 0:
            raise RuntimeError("Daq error: {}".format(res))

if __name__ == '__main__':
    daq_interface = DaqInterface()
    daq_interface.set_analog(512)

图书馆:Universal Library
接口:miniLAB 1008


Tags: 函数selfboarddataifdefchannelres

热门问题