Is there a disadvantage in terms of real-time performance when using Python as opposed to C++ in ROS2? If so, how significant is this disadvantage?

Thank you.


1 Answer 1


You're gonna hate this answer, but: "it depends", and on what you mean by "real time".

Yes, there's a disadvantage - python is slower than c++ (by a lot), and ros2's support for python is meh, and you have the GIL to contend with, and I don't think ros2's newest zero-copy stuff applies to python. But how much it impacts you depends on your usage.

For instance - are you reading from, and controlling a robot, at 1Khz in a tight loop? Then I bet you'd notice a difference in latency.

Are you doing computer vision at 20hz, and are spending all the time inside pytorch anyway? Then I bet you wouldn't notice a difference in latency.

The only way to know is to profile.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.