-3

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, self.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?

4
  • I don't think this is a valid C function prototype. Commented Aug 6, 2011 at 22:31
  • int equalwidth_quant(int target_num_state, FloatVec &raw_data, FloatVec &init_quant) That's not a C function. Commented Aug 6, 2011 at 22:32
  • Yeah, that's a C++ prototype all the way. Commented Aug 6, 2011 at 22:33
  • I'm thinking he wants to call equalwidth_quant from inside of get_quant. Then again, it's entirely impossible to figure out what's really supposed to be going on here. Commented Aug 6, 2011 at 22:52

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Downvoters, do leave a courtesy comment.
I don't even think you deserve these down votes since the problem is actually in the question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.