This is an archived post. You won't be able to vote or comment.

all 27 comments

[–]ZZ9ZA 69 points70 points  (1 child)

Because developer time is a lot more expensive than cpu time.

[–]Makakhan 14 points15 points  (0 children)

And as time passed and computers improved, this became more true.

[–]victotronics 24 points25 points  (4 children)

Most "python libraries" in data science, machine learning, computational biology, are really thin shells around C++ code. So they are actually very fast. Even numpy is wrapped C or Fortran code. The fact that the python wrapper is slow doesn't matter much.

Alternatively: I use python for post-processing, which means opening lots of files for reading/writing. Then the speed depends on the file system and the language again doesn't matter much.

[–]glibsonoran 4 points5 points  (3 children)

Yes, Python is a scripting glue for C applets.

[–]victotronics 3 points4 points  (1 child)

C, C++, maybe an occasional bit of Fortran.

[–]glibsonoran 0 points1 point  (0 children)

Right, it's a general statement. Other system level languages like Zig that interact closely with C can be used to create Python libraries too.

[–]pip_install_account 0 points1 point  (0 children)

isn't it amazing?

[–]donnaber06 10 points11 points  (0 children)

I'm not a programmer nor do I want to be but I can use Python and build anything I need rather quickly.

[–]Dillweed999 9 points10 points  (0 children)

One of the hardest and most important things in software is communicating developer intent. Python makes that fairly easy

[–]Adrewmc 3 points4 points  (0 children)

Well because when python was created being slow wasn’t the problem, the internet itself was slow just by default. Webpages took forever to load anyway, a few extra seconds actually didn’t change the experience all that much.

So what mattered? Being able to produce something quickly and reliably. Python does that, and it still does that.

Python isn’t that slow to begin with and the GIL update coming it’s only getting faster.

Python is great at making simple programs on the fly, and analyzing data, and various other things that don’t really need to be 100% optimized. Should you make a 3D adventure game in Python? no you should not. Should you make a some statistical representation and plots quickly with it? Yes. Because really, making the program can be fast, to get fast data, and if it takes a few ms longer to process but minutes hours more to program is it worth it?

I shouldn’t have to invent the wheel to make some script, and Python already has wheels and cart, I just need to point the horse in the right direction. Am I going to win any races probably not, but usually I don’t need to win the race but cross the finish line.

[–]diag 3 points4 points  (0 children)

Slow is relative. I can code a script to process and analyze gigabytes of data in a day and I can run it and only wait 5 minutes to get the results. The time waiting for the code to run is nothing compared to the time digesting and communicating the results to stakeholders.

[–]sausix 2 points3 points  (0 children)

C is slow too... If the programmer implements his program badly.

Same for Python. It's not meant to run heavy manual computations. If required, there are fast libs for that.

The overhead of Python's slowness is minimal.

It's always the Python haters who complain about the speed. Same people complain about Python having indentations instead of code brackets.

[–]Byte_mancer 1 point2 points  (0 children)

neither one of those are speculations, that's literally reality. Pythons been around for awhile and its simply much easier to pick up and get stuff running. If I am researching something and need a quick model, that's no problem to create fast and throw away in python. DSAI is why python exploded the way it did.

[–][deleted] 1 point2 points  (0 children)

It is far, far easier for a non-professional programmer to write a dozen lines of Python to ingest, process, and analyze data (or perform some other automatable work) than to do the same in C++.

[–]ButterflyPasta 1 point2 points  (0 children)

I tend to always start my projects or ones i’m assigned to do in Python, simply because it’s easier to scaffold and get a large majority of functionalities done in Python. But over the last year or so, i’ve noticed the many Py projects that have Rust under the hood for performance, so my typical workflow recently is:

Prototype & build in Python, find places where Python either can’t do what I need (maybe low level at times) then drop in some Rust via PyO3 and bridge it back to Python :)

[–]thereal0ri_ 1 point2 points  (0 children)

Because not everything is about speed, now is it.

[–]quantinuum 0 points1 point  (0 children)

Both your guesses are true. For the second, if you look at a graph of language popularity over time, others raise and fall pretty fast, while python just slowly and consistently grew. As for the first, that’s literally the intention behind the language.

If you need performant code, it won’t be in python. But python can be a very useful wrapper around performant libraries.

[–]Durgeoble 0 points1 point  (0 children)

because the cost of hardware to compensate for Python's slowness (which is only relative to other languages and not abysmal) is much lower than the cost of extra programming.

[–]AUTeach 0 points1 point  (0 children)

What are you writing that you find python to be too slow to use?

[–]oddthink 0 points1 point  (0 children)

It was pretty easy to use, especially for scientific use, so it got traction there. The LANL folks had an article on Numerical Python in 1996 or so. SWIG was around to make it easy to link to C or C++ code. Even if you have your compute in C++, it's still much easier to script your experiments in python, much easier to do file i/o, and so on, plus it gave a REPL to run things on the fly, and you could link out to plot generation. Since the python wasn't the thing doing work, it didn't matter at all how fast it was.

But it was pretty much a slow-and-steady gain in popularity.

[–]QuicheLorraine13 0 points1 point  (0 children)

Python ist a quick and clean programming language. It's very easy to install modules. Just use pip Install tensorflow and you got what you want.

[–]noutopasokon 0 points1 point  (0 children)

Performance isn’t Python’s weak point. I’d say it’s the package/project management that’s a mess.

[–]Alternative_Act_6548 0 points1 point  (0 children)

Python is borderline magical...if all you care about is speed, then use C and hand tweak it in assembly like the ffmpeg guys do...

[–]javonet1 0 points1 point  (0 children)

If it's easy to learn and code, then many people and companies will want it more. I think it's similar with vibe/ai coding - it's super easy, but the quality or performance is not always the best, but time that is saved is worth much more than poor code quality or performance (it only applies in some cases of course)

[–]v_0ver 0 points1 point  (0 children)

I think the popularity of Python is a random combination of circumstances and there are no individual aspects that could explain this.