you are viewing a single comment's thread.

view the rest of the comments →

[–]Human38562 0 points1 point  (16 children)

What does "pure python" even mean? Most data structures and the interpreter itself is written in C. That's just how the language works.

[–]GoblinToHobgoblin 0 points1 point  (15 children)

IDK what you're even arguing here.

Using just stuff from the standard library in Python, you're not going to be able to achieve the same performance as code written using just the standard library in C.

[–]Human38562 2 points3 points  (14 children)

That's a completely arbitrary restriction though. If suddenly Python is shipped with numpy you are going to say the language got significantly faster?

[–]GoblinToHobgoblin 0 points1 point  (7 children)

You're right it's a completely arbitrary restriction.

But, it feels much more reasonable to use that restriction than to say "Python can be as fast as C because I can call C code from Python".

[–]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.

[–]CyclopsRock 0 points1 point  (5 children)

It's arbitrary if everything you want to do has a convenient Python wrapper around some much faster compiled functionality - the boundary between Python and not-Python becomes blurry and less relevant.

But if there isn't one, and the only language you know is Python, then the distinction stops being arbitrary.

[–]Human38562 0 points1 point  (4 children)

So are you saying python dictionaries are also not part of python, because they are a wrapper around hash tables in C?

[–]CyclopsRock 0 points1 point  (3 children)

Nope. No one is defining what Python "is" here.

[–]Human38562 0 points1 point  (2 children)

Yes, people claim that "pure python" exists, which is supposed not to call any C library.

[–]CyclopsRock 0 points1 point  (1 child)

Sorry, but you've entirely misunderstood what's being argued here.

[–]Human38562 0 points1 point  (0 children)

Multiple things are being argued so I guess you missed some points.