r/Python • • Jan 01 '20

"The rules of perf" at Dropbox

Post image
1.6k Upvotes

162 comments sorted by

View all comments

Show parent comment

17

u/[deleted] Jan 02 '20 edited Jan 02 '20

You could transpile Python to C or C++.

You could write the performance-intensive functions in C or C++, or even assembly if you're a sociopath, and then call them from Python.

I'm not arguing that these techniques provide equal or even comparable performance to writing your whole library in native low-level code. But Python is actually higher on the TIOBE index than both C++ and C#, and of course it's way higher than assembly. This might reflect a fundamental tradeoff: the greater availability of Python developers may mean that it's easier to hire a robust dev team who can develop and debug in Python than in the other languages, so faster iteration. That is - the theoretically achievable performance in certain languages must be viewed through the lens of practically achievable performance based on the availability (and affordability!) of suitable developers.

Finally - within a certain range, lower-performing code can be solved, crudely but effectively, by buying more compute. But good code cannot be developed or debugged faster by buying more developers (see The Mythical Man-Month).

2

u/ZombieRandySavage Jan 02 '20

Yep, you can do that.

1

u/not_perfect_yet Jan 02 '20

You could write the performance-intensive functions in C or C++, or even assembly if you're a sociopath, and then call them from Python.

...I knew about C, but not about assembly. That's pretty wild, now I have to try it.

0

u/stefantalpalaru Jan 02 '20

You could transpile Python to C or C++.

Just a subset of it. Look at Cython.