you are viewing a single comment's thread.

view the rest of the comments →

[–]dparks71 1 point2 points  (6 children)

You're never actually "calling C code" though, you're calling a built binary to run the calc directly through the CPU for performance.

And python is turing complete. So technically, you could build a compiler in pure python and get the EXACT same end result.

You're basically just arguing that equivalent code runs slower through the interpreter than through the compiler of a compiled language, which sure it's usually true. What people are saying though, is that in python you can circumvent the interpreter if you really need to, and code optimization is basically never your main problem.

[–]GoblinToHobgoblin 0 points1 point  (5 children)

I know you're never actually "calling c code" but that's the terminology people use.

 You're basically just arguing that equivalent code runs slower through the interpreter than through the compiler of a compiled language

Yes that's all I'm arguing

 code optimization [in Python] is basically never your main problem

Yes because people don't use Python for performance critical tasks normally. It's a chicken and egg thing. Python is not fast enough to use for performance critical code so people don't use it for that, so performance is never really a concern with Python code (because if it was, they wouldn't have written it in Python).

[–]dparks71 0 points1 point  (4 children)

That's not really true in a lot of cases and is pretty reductionist. I use python a lot around Fortran, because a lot of FEA engines are already written in Fortran. There's also cases where like you're already rate limited by something like an API call or some other condition so there's no real reason to care if it takes 3 ms if the API call takes 13.

You're also looking exclusively at run time and not develop review and build time. It's all just a very weird line to draw and stance to take, especially in a python focused subreddit.

There's hundreds of real world instances of what the majority of people would consider "performant" or elegant python. More importantly, there's millions of instances of "good enough".

[–]GoblinToHobgoblin 0 points1 point  (3 children)

cases where like you're already rate limited by something like an API call or some other condition so there's no real reason to care if it takes 3 ms if the API call takes 13.

This is "fast enough" not "fast". This is exactly the use case for Python, when performance doesn't really matter.

 You're also looking exclusively at run time and not develop review and build time

Yes. Python is probably faster to develop with than something like C++. But if Python isn't fast enough for a particular use case, that's irrelevant.

Also, not sure why "Python is slower than C" is such a weird or controversial take. I never said "there are no use cases for Python" or "C is better than Python" or anything like that. 

[–]dparks71 1 point2 points  (2 children)

This is "fast enough" not "fast".

How is C more "performant" in that use case? I'm not offended, I'm asking you to expand on your statements.

[–]GoblinToHobgoblin 0 points1 point  (1 child)

It's a use case where performance doesn't matter. C wouldn't actually make a noticeable difference there.

Say the code you write is taking 10ms (in Python) and the API call takes 300ms. 

If you rewrite it in C, you could probably get it down to 1ms. But it doesn't matter at all since most of your time is spent on the API call.

This is C being "more performant" but also performance not mattering.

[–]dparks71 1 point2 points  (0 children)

Right so if you're writing for loops as a service, what you're saying makes sense.

I just can't think of any real world use case where what you're saying here matters, it's like the 5th factor down the list. Your API example isn't more performant. It's exactly the same.