O
O
overmes2012-08-20 20:02:35
Python
overmes, 2012-08-20 20:02:35

Should I run C++ from Python?

there is a function that receives point A and a list of points, calculates the Euclidean distance from point A to all points in the array
of points A is many and the array of points is very large, so here I have a bottleneck

, everything is complicated by the fact that the point is a dictionary that represents a multidimensional space (1.0 - 2k) and at point A many spaces may not be defined

transferring a dictionary to a sheet is not desirable

Is it worth making this function in C ++?
after a little searching, I realized that it is not so simple
. If it is, then what is preferable?
in Boost.Python I never found what to download, there is a ton of binaries
PyCXX is preferable, but it doesn’t compile,
otherwise what is poorly described in the standard library
If I make this function in C++ will the memory consumption increase?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
avalak, 2012-08-20
@overmes

There are options:
- use PyPy . JIT. speeds up code execution.
- NumPy is a library for scientific computing.
- Cython - A superset of python for easy writing extensions.

@
@resurtm, 2012-08-21
_

If so, what is preferable?

More ways:
- SWIG (supports many languages, including Python);
- ctypes - creates a library in C with the necessary functionality, collect it and call functions from the created dll/so/pyd;
— Python C API .
If I make this function in C++ will the memory consumption increase?

More than likely it will decrease. Variables in Python require more memory than variables in C (eg due to metadata, etc.).

M
MikhailEdoshin, 2012-08-21
@MikhailEdoshin

Write a library in C with the desired function. Memory consumption will increase by the size of the resulting library, but I understand that you mainly need speed. As an option, write in Cython, in this case it will be almost the same as with hands in C.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question