0

I am mainly using python for extensive algorithms operations. Now i have my webiste in Django.

I few libraries in c++ and few in Java which i don't have in python. Or you can say that i already have some c++ , Java files in which some algorithm is coded.

can i call those function or do some calculation in my djnago sites using those c++ or java files

0

3 Answers 3

2

For C++, certainly. Either write a module that wraps the library, or use something like ctypes or SWIG.

For Java, you'd be best to move to Jython (and correspondingly use django-jython).

Note that using both C++ and Java from Python is not trivial.

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

5 Comments

sorry but my english is not so good so u mean not trivial means not easy means difficult. So u mean people r not using it
It takes a decent amount of both knowledge and skill to be able to bridge C++, Java, and Python.
It might be possible to compile the Java code to native library with gjc and use the C method on it, but even if the library actually compiles, it would still be hard.
ok , but i will not be using it initially , i was just asking if thats possible or not. Actuaaly i want to implement Genetic algiriths and optimaztion algos in python , i have books in java and c++ which explains the code and working but not in python. so i thought i need arises i can bridge them. there are libraries in python as well but i want to code myself
The only way for a novice to get this working is to use Jython instead of Python to call Java methods. As long as you don't have the Java code (but only the text in the book) I suggest to simply rewrite it in Python. That should be easy.
0

I've used Boost.Python to some degree of success for accessing C++ libraries within Python/Django.

Comments

0

You could check the http://www.scipy.org/Weave weave package for C/C++. I didn't use it myself, but I know it exists

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.