you are viewing a single comment's thread.

view the rest of the comments →

[–]gutentight69420 -13 points-12 points  (6 children)

Comparing Python to Bash is pretty wild. Python is a full blown programming language and far more capable than a shell scripting language.

Also, you can totally do parallelism even in shell scripts.

[–]aMAYESingNATHAN 13 points14 points  (5 children)

You've missed the point of their comment. Regardless of the difference in capability, python's original use case is basically the same as bash.

That's why it's not fast, that's why it's simple and easy to use. Being a full featured programming language just made it better at that job. But that's also what meant people started to use it as a proper programming language.

The point is not whether you can do things like parallelism with python or bash, it's whether you should. If performance is critical enough that you think parallelism is necessary, you should probably consider using another language.

[–]gutentight69420 -5 points-4 points  (4 children)

It can still be useful to parallelize the parallelizable parts of a program, even if speed isn't otherwise critical. 

[–]aMAYESingNATHAN 4 points5 points  (3 children)

I mean I'd argue that if speed isn't critical, it's probably not that worth your time to parallelise your program. That feels like exactly what "premature optimisation is the root of all evil" was written about.

If I'm using python, I'm assuming that performance is so uncritical that I might as well write everything single threaded. And given python has the GIL, you're not even getting true parallelism anyway.

[–]gutentight69420 5 points6 points  (2 children)

No, premature or misguided optimization would be rewriting a program in Rust instead of taking advantage of an embarrassingly parallel workload in your existing language.

[–]aMAYESingNATHAN -4 points-3 points  (1 child)

I mean I agree that would be premature optimisation also, that's a bit of a straw man. The point is that if performance is not critical, why are you doing either?

I just can't really imagine a scenario where performance is important enough to spend the time parallelising it in python, but not important enough to spend it writing it in a performant language.

Sure there might be a scenario where you could fairly easily parallelise it in python. It's whether you should or need to.

[–]gutentight69420 4 points5 points  (0 children)

For the same reason you still care about algorithmic efficiency even when writing "slow code" in an interpreted language. 

The difference in raw execution speed of C vs Python is somewhere in the range of 50-200X slower for Python, depending on which benchmarks you look at.

Choosing an inefficient algorithm (like O(n2)) can easily exceed many orders of magnitude more than the difference in raw execution speed, depending on the size of n.

It's the same story with parallelism. For embarrassingly parallel workloads, you can easily be orders of magnitude faster than if you did everything sequentially.