Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Performance of C++ vs. Python

Message 1 of 3
898 Views, 2 Replies

Performance of C++ vs. Python

Hello all,


   My main question is if people could give specific situations where C++ would run noticeably faster than Python.  I only know Python and am comfortable using it with the API; I like how quickly I can develop and experiment with a script using Python.  Though I am considering learning C++, especially if it will run faster compared to python when it comes to generating a lot of new entities and features.


Any and all input is appreciated,



Message 2 of 3
in reply to: J_Gow

I'm not aware of any benchmarking that has been done to compare the performance between the two languages when used for Fusion 360 programming.  But you also have to be careful when looking at any benchmark results because depending on what the test actually does the results can be very skewed.  But also because everyone will be using the API in different ways, it's likely that any performance test will not correlate exactly to how you'll use Fusion and the API.  Here are some things to consider.


Code that's not calling any Fusion API functionality but is staying completely within C++ or Python will be much faster in C++.  You can search for performance tests between the different languages online.  One of them that I found that has been testing many languages over several releases reports that generally Python is 15 times slower than C++.


However, you're also using the Fusion 360 API so there are some things to consider there.  The Fusion API is implemented internally in C++ with wrappers for Python and JavaScript.  When you make an API call it has a slight overhead of going through the wrapper so to make any API call it will be slightly slower using Python.  I haven't done any testing for this so I don't know how much slower.  Once the API call reaches Fusion and it does the actual work, that will be identical between C++ and Python.  It's the same internal function being called in both cases.  Once the work in Fusion has finished, the result needs to be returned, which then also has to go through the wrapper for Python.  I don't expect this wrapper overhead to be very much so I wouldn't be too concerned with it.  It also depends on how many API calls you're making.  If you're making thousands of calls then even a small amount can add up, but this also isn't typical.


I believe the programs where you would see the biggest difference are those that do a lot of their own processing outside of Fusion.  For example, I wrote an application that's on the App Store that draws sketches that represent a section through a mesh body.  This uses the Fusion API to get the mesh information from the mesh body but then it does all of the work to calculate the intersections using its own math and not any of the Fusion API.  Based on the benchmark I referenced above, this part of the program would likely run 15 times faster if it's written in C++.  The rest of the program that getting the mesh data and creating the sketch will probably not be that much different between C++ and Python.

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3
in reply to: ekinsb

Awesome, thank you for the quick reply.  That answers my question.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report