开发者

Interfacing C and Python [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Calling C/C++ from python?

I am looking to bridge a C++ and python code.

The interfaces needed by python code are :

floatvect(): this one should return an empty float vector (basically a list)

get_quant(input_list_2, s开发者_运维技巧elf.m_state_num, self.m_qm_vector)

The corresponding C++ function is :

int equalwidth_quant(int target_num_state, FloatVec &raw_data, FloatVec &init_quant)

When my python code contacts get_quant, it should be able to call the corresponding C++ function and get the result. The result is basically stored in the last attribute of that C++ function.

Is there any specific libraries which I can use for achieving this?


You need to write equalwidth_quant as a C-extension for Python. Check out Cython or here's a simple tutorial.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜