By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

from c++ to python

luke14free
P: 79
Hello to all,
I am a python user and i would like to use a c++ extension in python (because i am forced to do that!) but i dont know where to start, on the where there are:

1) swig that requires a mid passage and requires a knowledge of cpp(that i really dont have)
2)pycxx that comes without docs and hasnt got any documentation on the web

Thank you

ps: if you want to see the script i am trying to use in python goto:

http://forum.nokia.com/info/sw.nokia.com/id/8b3a6ed3-e833-4f7c-aee1-4c773196f894/S60_Platform_Full-Duplex_Audio_Example_v2_0_en.zip.html

PS: I am posting the same post on the c/c++ forum in order to see if anyone knows how to solve my problem there.

Thank you,
Best regards
(feel free to correct my english)
May 8 '07 #1
Share this Question
Share on Google+
5 Replies


bartonc
Expert 5K+
P: 6,596
Hello to all,
I am a python user and i would like to use a c++ extension in python (because i am forced to do that!) but i dont know where to start, on the where there are:

1) swig that requires a mid passage and requires a knowledge of cpp(that i really dont have)
2)pycxx that comes without docs and hasnt got any documentation on the web

Thank you

ps: if you want to see the script i am trying to use in python goto:

http://forum.nokia.com/info/sw.nokia.com/id/8b3a6ed3-e833-4f7c-aee1-4c773196f894/S60_Platform_Full-Duplex_Audio_Example_v2_0_en.zip.html

PS: I am posting the same post on the c/c++ forum in order to see if anyone knows how to solve my problem there.

Thank you,
Best regards
(feel free to correct my english)
A third option (which I have experience with - tried SWIG - too complicated) that might work for you is the ctypes module. It's included in version 2.5 and can be added to 2.4 (maybe even 2.3). It's basically a DLL loader with varailbe types that can be passed directly to C. I use it quite often for advance Window programming and it works very well.

Hope that helps,
Barton
May 8 '07 #2

luke14free
P: 79
very nice answer! Do you remember me? I am the man of the process handling, and you suggested me to use ctypes...And it worked...
How could i didn't remember for a c library??

Thank you
May 8 '07 #3

luke14free
P: 79
Sorry, i have just check the compatibility of dlls with python for nokia series 60 and it is uncompatible...what a pity, it would have been great!
so, have you got other ideas?

Thank you
May 8 '07 #4

bartonc
Expert 5K+
P: 6,596
Sorry, i have just check the compatibility of dlls with python for nokia series 60 and it is uncompatible...what a pity, it would have been great!
so, have you got other ideas?

Thank you
The ctypes module is capable of handling libraries compiled with different call types:
windll uses stdcall. There are others that I'm not familiar with and I dont't have 2.5 installed on this maching. But this online doc says:
You load libraries by accessing them as attributes of these objects. cdll loads libraries which export functions using the standard cdecl calling convention, while windll libraries call functions using the stdcall calling convention.
May 8 '07 #5

luke14free
P: 79
So i should (using software a svisual studio...) create dlls with inside all the modules that i needed in c and then call them with python...it seems not so easy...
and however please look ath this http://pymbian.sourceforge.net/misc/statichack/INFO

Best regards,
Luke14free
May 8 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.