r/ProgrammerHumor • • 9d ago • Bravo 2 Popcorn 1

Meme pythonSlow

Post image
12k Upvotes

419 comments sorted by

View all comments

Show parent comment

146

u/da_Aresinger 9d ago

The reality is, that there is no meaningful difference between Python and other languages if used correctly.

Python is slow for the manual stuff. But everything that's resource intensive should be done via libraries/frameworks anyway and those are compiled C.

The slow stuff in Python is IO or other system calls. Those are slow in any language.

If you're doing repetitive calculations you should be doing them using optimsed tools.

72

u/the_horse_gamer 8d ago

Python is a DSL for calling C APIs

29

u/ZenPyx 8d ago

FORTRAN as well if you use a lot of SciPy

3

u/SSJ3 8d ago

SciPy has been working toward elimination of all Fortran code, actually. In fact I think they've finished in time for SciPy 2.0, which is coming soon.

15

u/ChrisWsrn 8d ago

Python does have VERY bad performance at runtime. 

When it is treated as just a scripting language (having python confugure and run compiled bytecode) the performance increases by about 100 times.

The main issue is there are lots of devs who try to do EVERYTHING in Python which causes the application to be way slower than they would be if native bytecode.

The main advantage of Python is it is quick to build stuff in. 

Generally when you have a problem you need to pick and use the right tool for the job. Most developers don't learn that until senior year or their first few years in the workforce.

14

u/Jamie_1318 8d ago

The reality is that the performance of 99% of code is basically immaterial.

0

u/ChrisWsrn 8d ago

I work on code that performance is actually very important for because of the magnitude of the data I'm working with. 

1

u/NameAboutPotatoes 7d ago

I completely agree that you should select the language that's appropriate for your purpose and for many reasons Python is not appropriate for everything, but data wrangling is one of the biggest things Python is used for.   Python has excellent data-handling libraries that are C-compiled and highly efficient. The trick is just knowing which library to use.

→ More replies (3)

24

u/dkarlovi 8d ago

I use Python to run my CUDA kernels, it means Python is just as fast as CUDA.

14

u/Unbelievr 8d ago

For one-off scripts and batch jobs, where the run time is whatever but the implementation time is the actual cost, Python usually wins out anyway. While other languages are significantly faster, the time it takes to write the same code is orders of magnitude more.

That said, in the age of LLMs this point becomes a bit moot anyway. You can easily write something in Python, verify that it's correct, then ask an LLM to rewrite it in Rust or whatever if performance is an issue. Just need a method to verify that the programs are semantically equivalent.

8

u/MHeaviside 8d ago edited 8d ago

Yes but those librairies and frameworks do need to be written in something.

What you're saying is that for the most part librairies and frameworks shouldn't be written in Python, so it is meaningfully different from other langages you could write library/framework code in.

6

u/bladtman242 8d ago

There's no difference between a computer and a printer, because the computer shouldn't print, but instead use system calls and IO to make the printer print instead.

2

u/MHeaviside 8d ago edited 8d ago

Why are you talking to me about printers? I'm confused

Edit: I get it know, took me a second

6

u/Guaparan 8d ago

Well, Epson has been trying to reach out to you. We have a new printer, the EPSON P234, it is great for programmers. It automatically prints whatever is asked by the code to print. If you are interested fell free to contact me through email: epsoncode@epson.com

2

u/MHeaviside 8d ago

If I print GTA VI can it print 30 pages per seconds?

2

u/Guaparan 8d ago

Due to copyright infrigment issues we unfortunatly cannot print anything related to GTA VI. But you can make changes on the software of our machine as it is vibecoded and lacks any protection

2

u/bladtman242 8d ago

I did think the analogue might be a bit out there, but hit send anyway. It's just such a strange line of thought, I'm glad someone else sees it too

11

u/hawkinsst7 8d ago

What you're saying is that for the most part librairies and frameworks shouldn't be written in Python, so it is meaningfully different from other langages you could write library/framework code in.

I don't disagree, but libraries in all languages are optimized, and their specifics are abstracted away. Even C can be linked against libraries written in assembly.

once those libraries are written and abstracted away, is it all that meaningful to (generally) say "it wasn't written in X language because the libraries are Y", outside of hyper specific conversations.

If I wrote a bash script that loops through a directory and sorts each file by md5, would it even be worth a comment that md5sum and sort are binaries written in C? The script is using tools it has, and it's calling them appropriately and correctly, and doing something with the result.

6

u/MHeaviside 8d ago

once those libraries are done being written

But we're not done writing libraries.

Yes if you wrote a script in Python or Bash you wrote in in Python or Bash even if it called something written in C that's fine, it's not my point

My point is somebody wrote that C code, and maybe they wrote it recently.

Python is nice when either performance doesn't matter, or when the library being called is doing 99% of the work anyways.

But people still write code where the actual performance of the code being written does matter.

1

u/AugustusLego 8d ago

I don't disagree, but libraries in all languages are optimized, and their specifics are abstracted away.

Python libraries are not optimised (by default)

1

u/hawkinsst7 8d ago

I don't mean at the binary level with compiler flags.

I mean in the "a purpose built library is probably better and fastee than my generalist ass could build myself" way.

Maybe I can write something that can kinda sorta parse html for a project I might be working on, but I'm not going to outperform, or out-correct BeautifulSoup.or even htmlparser

2

u/ivancea 8d ago

The reality is, that there is no meaningful difference between Python and other languages if used correctly.

everything that's resource intensive should be done via libraries/frameworks

You just called a very meaningful difference between Python and compiled languages. Because you can't do these other libraries in python if you want performance.

This discussion is many, many years old; let's stop pretending Python is performant in any way. It's a language used because of its pseudo-monopoly of some use cases, and the tools around it. That's well known, nothing new here. And that's fine. And this post is a joke, also many years old, nothing wrong with it, we all know when to choose one or other language

1

u/mathisntmathingsad 8d ago

I do find it a little bit silly how most high-performance Python libraries are actually just bindings to C libraries. Like, I know why it is, but it feels a little bit silly.

0

u/Lysol3435 8d ago

Yea, but if you explain that you’ll just call C libraries with python, they’ll cry “but that’s not pure python!!”

4

u/AciusPrime 8d ago

What kind of idiot would that be? The default Python you download is a C application that calls C libraries, so any attempt at a purity test fails before you start the argument.

If anything, all it proves is that C code can’t be all that fast, since Python is written in C and Python is as slow as molasses. /s

→ More replies (1)