The performance between c++ script and python script #4984
-
|
Hi there, I'm currently working on a real-time simulator project and I've found the SofaPython3 plugin to be extremely helpful in reducing the learning curve for me. I'm curious to know if writing scenes in Python is significantly slower than in C++, and if the choice of complie language matters a lot. In what scenarios would it be more beneficial to choose C++? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @Junang-Wang Thank for your question and the feedback. In most of the cases writing a sofa scene using SofaPython3 does not have impact on performance compared to writing it with xml or c++ (with the "simpleapi.h"). This is because writing a scene consists in fact in assembling existing components and that the assembled component are in fact written in c++. So if you are more confident with python than with c++, do with it to write scenes. Nevertheless, in the specific case of having a scene with custom components written in python (like python controller or forcefield) ... then there can be a difference between python and c++ performance on computation intensive part of the code (if any). When performances matters, the general recommendation would be to:
And regarding Sofa, here is what I'm doing:
There is also this page related to how to get good simulation performances: |
Beta Was this translation helpful? Give feedback.
Hi @Junang-Wang
Thank for your question and the feedback.
In most of the cases writing a sofa scene using SofaPython3 does not have impact on performance compared to writing it with xml or c++ (with the "simpleapi.h"). This is because writing a scene consists in fact in assembling existing components and that the assembled component are in fact written in c++. So if you are more confident with python than with c++, do with it to write scenes.
Nevertheless, in the specific case of having a scene with custom components written in python (like python controller or forcefield) ... then there can be a difference between python and c++ performance on computation intensive part of the code (if a…