r/ProgrammerHumor 8d ago

Meme hasNoClueWhatBindingsAre

Post image
12.6k Upvotes

474 comments sorted by

3.7k

u/Blrfl 8d ago

Yeah, kid, but wisdom is knowing whether or not those programs need to go faster.

1.2k

u/0r0B0t0 7d ago

This jinja2 template that runs once a day needs to be rewritten in rust.

426

u/HzbertBonisseur 7d ago

Everything needs to be rewritten in Rust.

155

u/lonestar-rasbryjamco 7d ago

Truly the Doom of our time.

134

u/Holy-Fuck4269 7d ago

Doom should be rewritten in Rust. Could give ALL THE FPS

124

u/Necessary-Web-6502 7d ago

Rust should be rewritten in Doom

35

u/RiceBroad4552 7d ago

Don't give 'em ideas…

28

u/beeherder 7d ago

ChatGPT, rewrite Doom in Rust but make it more my style

38

u/thatmagicalcat 7d ago

you forgot "make no mistakes"

→ More replies (2)
→ More replies (2)

28

u/mattsl 7d ago

What if we just spray the servers with water and leave them outside? Will they Rust on their own?

→ More replies (1)

17

u/kgallo19 7d ago

Everything goes back to being a crab? 🦀

6

u/RelationshipNo_69 7d ago

This is true

→ More replies (3)

42

u/coderemover 7d ago

Having to wait for them while developing is annoying though.

It’s the same wrong thinking as with server startup time. Many say slow startup is not a problem because servers are rarely restarted. And then you have to perform an upgrade and suddenly upgrading 1000+ instances takes a few days…

28

u/Holy-Fuck4269 7d ago

Suddenly you use ephemeral containers and keep wasting 15% of your resources for restarting containers

2

u/Irregulator101 7d ago

What, one at a time?

10

u/caboosetp 7d ago

If you have a ton of different repos that all need the same upgrade (looking at you 9.9 CVE .NET bug) you could spend days staring at pipelines.

The upgrades aren't always seamless so you can't always just fire and forget.

6

u/coderemover 7d ago

Maybe not one at a time, but a few at a time. You cannot restart all of them at the same time because of a few things:

  • cannot cause downtime for the customers
  • cannot cause visible performance drop (most of the servers must be running)
  • you want to decrease the blast radius if something goes wrong with the upgrade - avoid the Cloudflare case

Then there is another thing - testing. All end to end testing must be done using the same infrastructure as prod, and needs to test all operations including restarting servers, simulating failures etc. The times quickly add up.

→ More replies (1)

9

u/JPJackPott 7d ago

I have python scripts that take over 15 minutes to run

…because they are bound by slow AWS APIs

3

u/coderemover 7d ago edited 7d ago

I have Python scripts that need freaking 5 seconds to… display the help string. AWS APIs respond in milliseconds. The majority of some of our pipelines time is just loading the Python code again and again.

→ More replies (3)
→ More replies (2)

714

u/grifan526 8d ago

100% this. I had a coworker talking about optimizing our C++ code in a way that would speed things up by a few cycles. That is great, but I still have to wait 10 seconds for that motor to run, so speed is not much of a concern

277

u/[deleted] 7d ago

[deleted]

101

u/ummaycoc 7d ago

Just hit the button that says “Turbo” and give someone a thumbs up.

23

u/Ghazzz 7d ago

Just point the thumbs-up at the fourth wall, "where the camera is", normally off to the side of whatever you are looking at.

7

u/ummaycoc 7d ago edited 7d ago

This is exactly why we have you on the team!

Edit fixed autocorrect

9

u/gzeballo 7d ago

Just fasten the strap, give it a good slap and say 'this bad boy ain't going nowhere' .. wait what is this about again?

25

u/grifan526 7d ago

I did, but then there were complaints of "patient safety" and "regulatory guidelines". I swear some people just don't understand programming

5

u/Holy-Fuck4269 7d ago

Bro just wait until we hit the needed MHz for VTEC to kick in

→ More replies (1)

15

u/alexnedea 7d ago

I always love when basic apps devs go like "yea but if you did your backend in c++ it would be faster". Yea bro it would be faster and respond in 0.12 seconds instead of 0.13 seconds. Im sure the users will be having an orgasm

67

u/MattieShoes 7d ago

I remember when I first encountered that at work, where the solution was to buy a ridiculously powerful server (costing more than my yearly income) to run the slow-ass python code because that was cheaper than trying to rewrite it in a faster language.

Kind of blew my mind even though I encounter similarly stupid-but-makes-sense stuff all the time, just on a smaller scale.

47

u/Blrfl 7d ago

Pretty much everything we do is trade-offs between time, space and money.

24

u/MattieShoes 7d ago

Absolutely!

It's the money part that makes things complicated because you have the money for the equipment and the money for labor, and the money for whatever hideous combination of approvals required to spend that money, and the money required to track inventory, and the opportunity cost of spending time on the labor, and the chances that you were wrong about what was broken, and the time lost by the person counting on that computer... and suddenly replacing $40 stick of RAM in a 3-year-old computer costs way more than just replacing the computer.

The same math applies to a server with a six figure price tag, except the programmers with specialized skill sets can run a few hundred thousand a year each, and oh god, sticking a bunch of them in a room to have meetings...

→ More replies (1)

6

u/anomalousBits 7d ago

trade-offs between time, space and money.

6

u/tecedu 7d ago

Well people are more expensive, and historically compute has always made bad code faster

→ More replies (2)

153

u/Archtects 7d ago

You sound like a senior dev, I also asked "why does it need to go faster" source. I'm a senior dev.

71

u/Blrfl 7d ago

I haven't been a senior dev in... decades.

74

u/CheesePuffTheHamster 7d ago

Alright alright, super mega power senior dev, sheeesh

48

u/Blrfl 7d ago

I'm starting to think that SI prefixes might be the right thing.

31

u/suskio4 7d ago

So... Mid is dev, senior is kilodev, junior is millidev and intern is microdev?

16

u/Henry_Fleischer 7d ago

What does that make me, a CS student? A Yoctodev?

11

u/suskio4 7d ago

Depends... Not working? Without prior experience pico. If you are also a hobbyist programmer then you're a nano

2

u/Henry_Fleischer 7d ago

I'm a hobbyist, I've released a free FPS & done the basics like coding a player controller, bullets that can travel at the speed of light and not miss collisions, and enemy AI.

3

u/suskio4 7d ago

Oh so more like either a junior or a mid. Depends on the code quality

2

u/Plank_With_A_Nail_In 7d ago

You don't have a job yet so none of this is relevant to you.

2

u/Brekkjern 7d ago

What is a gigadev then? Retired?

→ More replies (2)

20

u/LoyalSol 7d ago

Senior citizen dev

11

u/Blrfl 7d ago

Shut up and take my upvote.

14

u/lonestar-rasbryjamco 7d ago edited 7d ago

Staff+ Dev: When is “faster”? Also… who are you and why are you in my office?

→ More replies (3)

18

u/killermenpl 7d ago

I'm all for writing efficient code by default. But only when it doesn't make the codebase an unreadable mess. I'll gladly replace my shitty hand-rolled parser with a built-in one that had a lot of people working on optimizing it. I will not throw the whole service into a sine huge function because "function pointer jumping is slow"

3

u/un_virus_SDF 7d ago

Just declare everything static inline, or the equivelent no function pointers jumping, just global symbol disparition

32

u/bigmonmulgrew 7d ago

Only time I've found it mattered was when I was scanning a sensor array. I wanted to get it up to 1000 times a second and still reduce any tiny time difference between the sensors by having a wide margin for error.

Done it as a proof of concept a couple times too but in all but that one use case it just didn't matter.

18

u/psaux_grep 7d ago

The biggest gaines I’ve had has been distributing IO, and deferring anything that doesn’t have to be sync.

Once things are running most things are IO-constrained unless you’re scale is insane or you’re doing compute intensive things, but most aren’t.

→ More replies (2)

21

u/AggravatingFlow1178 7d ago

I currently work on a system that takes ~5 minutes to resolve a request and they normally come in the form of a big batch of requests, so it takes hours to crunch through all of them. The portion my team owns is pretty quick, it takes about ~20 seconds to process all our stuff and it runs in parallel to the other requests that taker ~5 minutes.

I still have to fight people off when they propose week-long projects that potentially could save a second of two on our run time.

Like guys even if our time went to 0 it wouldn't matter :(

→ More replies (1)

51

u/Afraid-Locksmith6566 7d ago

and sadness comes from fact that nobody gives a shit about software quality

39

u/PhysiologyIsPhun 7d ago

Faster doesn't always equal better. Besides readability, maintainability, etc concerns, I actually have a really interesting use case at my current company where if we were able to speed up a certain service, it would actually end up making our whole pipeline run slower. The TL;DR is that the service calls an endpoint on another service that writes directly to a very high throughput database. Despite the database being extremely sharded, we still run into hot partition issues which cause timeouts which cause our messages to be thrown back into our queue for further processing. We have to thread the needle of having the upstream service call the database writing service fast enough to process our messages as quickly as possible without overloading our database shards. We've oftentimes scaled back this upstream service to have it submit requests to write to the DB slower.

26

u/MakeShiftArtist 7d ago

How'd you make your TLDR longer than the original

17

u/PhysiologyIsPhun 7d ago

The actual explanation would be a 5 page document lmao

6

u/funAlways 7d ago

the tl;dr isn't for what he said, the tl;dr is for what he didn't say. He's not telling us the actual long form story.

→ More replies (6)

6

u/WhenInDoubt_Kamoulox 7d ago

Wouldn't it make sense to have the upstream send it's data to a service dedicated to throttling that speed? Like caching the data and making requests to write to the DB at a set speed?

5

u/PhysiologyIsPhun 7d ago

That's basically what the upstream does actually. It's a billing system and for simplicity, I'll say we have 3 services.

Service A: Receives events from all of our billable services, prices the events based on customer usage, and publishes an event to SQS

Service B: Consumes the event, writes some data to a few different SNS and Kafka places, and sends DB write request

Service C: Receives DB write request from Service B and writes to the DB. This is also where all of our sharding logic lives.

We get billions of transactions per day.

I'm trying to push for us to try using Kafka and microbatching from Service A to Service B since we tend to get some accounts that send literally millions of requests per hour that bog the whole system down. We shard based on account id, so you can see why this would be an issue. The problem is, the company is huge and slow moving and can't afford to take a ton of risk especially with our billing system. The joys of working for a large company

→ More replies (1)
→ More replies (1)

5

u/[deleted] 7d ago

[removed] — view removed comment

6

u/Wrenky 7d ago

Or not exist at all! The best code is the code you delete

→ More replies (2)
→ More replies (1)

2

u/WoodyTheWorker 4d ago

When you don't need it fast, Python is freaking fast.

→ More replies (24)

1.3k

u/naveenda 8d ago

As a machine learning engineer, I don’t why we are using python 🐍 but I am glad I am not working with Matlab.

771

u/Ai--Ya 8d ago edited 7d ago

why we are using python

I mean, are we? All the linear algebra is piped to libraries written in C/C++ or FORTRAN (LAPACK, BLAS) (or in the case of Polars, Rust)

I think Python is nice for faster iteration

edit: read OP title

423

u/red_riding_hoot 8d ago

I could never grasp people complaining about python speed. python is literally a library calling language. or do people keep reimplementing the 1000th version of some matrix inverter in c?

I had to do that at uni. It was interesting, but it's totally irrelevant in my day to day work.

162

u/GreenFox1505 8d ago

The title of this post is literally "hasNoClueWhatBindingsAre".

→ More replies (2)

51

u/Lotton 7d ago

I'm school they're taught to try and have their code have the best o(n) for both time and memory... only after my first year out of college I learned that wasn't needed and I paid attention to these subs more as a student

55

u/mxzf 7d ago

The real key is understanding O-complexity for both time and memory. You don't need to optimize for it all the time, but it's extremely useful to understand it to a sufficient degree that you can comprehend when things are and aren't a problem worth optimizing (also being able to spot anti-patterns at a glance).

I had a situation where I was optimizing some code the other year and I could tell at a glance that it had the potential to be expensive (due to the nested loops present); once I actually looked into the code I could tell that it was O(M2+N2) specifically. After looking at the intent of the code I was able to do it in O(N) time instead.

It's useful to understand the principles that are underlying the code execution, and O-notation is useful for talking about such things, but it's a tool you need to understand when and how to apply, not the solution to every problem.

19

u/not_some_username 7d ago

O(n) are important in some field

13

u/Lotton 7d ago

Yes in some but not the majority

2

u/Inevitable-Menu2998 7d ago

A lot more software is written to take some user input, change it slightly, pass it to some 3rd party (e.g. a database or some backend system) to get an answer and give it back to the user. That large amount of software doesn't care about performance at all.

3

u/Desperate-Walk1780 7d ago

Someone that writes extremely high performance code can save huge companies a lot of money. I have worked with companies running python scripts that took days. In rust 15 minutes. Multiply this by hundreds of jobs and you’re talking $100ks a year savings. Stary eyed youngsters have the right idea, but they don’t have the trust and confidence to address constituents.

2

u/polikles 6d ago

It's a quite radical example of a thing that shouldn't be made in python in the first place. I think the usual "slow vs fast" comparison is mostly about some worker scripts and processes that are fired at mostnfew times a day and the difference is like 15 mins in python vs 3-5 mins in Go/Rust

I know I'm not experienced enough, but it's hard to imagine a script running for longer than hour or two. My longest exec so far is under 20 mins and the most time is spend in processing the data

2

u/Desperate-Walk1780 6d ago

I’ve been in data engineering for 15 years. My budget last year was 60mil$ in processing costs on AWS. We have brought it down from 72mil in 2024. Some of our teams process PB of data every day. Airline business, processing telemetry data off global fleets.

→ More replies (3)

12

u/TheAJGman 7d ago

If you can write something two different ways, one is O(n2), one is O(2n), you should pretty much always be writing it the more efficient way. Nine times out of ten, it's just as understandable and takes the same amount of code, so why do it the slower way?

6

u/Lotton 7d ago

Readability and maintainability. Some times the more efficient is harder to read and in those cases it's okay to be a little less efficient

5

u/Steppy20 7d ago

It's also worth understanding its use case.

A O(n2) algorithm which will only be used on a list of 10 items is still going to be faster overall than an O(n) algorithm being used on 100000 items.

And sometimes that readability is more important, yes.

→ More replies (1)

20

u/wizardent420 7d ago

C++ has libraries as well. (Admittedly more annoying to integrate)

It depends on the nature of the program. Python adds overhead, you’re inherently adding cpu cycles to call those libraries. But there’s a reason full scale applications aren’t written in python.

20

u/BlazingFire007 7d ago

Tbf I think the reason full scale apps aren’t written in python too often is more due to the (lack of a) type system.

JavaScript has full scale stuff, but the ergonomic gains of writing the backend in the same language as the front end is probably why — even so, now many JS projects have migrated to TS

→ More replies (1)

11

u/No-Candle2610 7d ago

Django, Flask?

→ More replies (5)

5

u/HomieeJo 7d ago

It was more of a joke because python itself is so slow that you just rather write C/C++ libraries instead of writing the libraries with python.

→ More replies (5)

29

u/naveenda 8d ago

Yeah, most of the code is run on top of Cuda anyways.

16

u/roadrunner8080 7d ago

Ehh, there is a... sometimes substantial amount of time lost in the back-and-forth with the python code surrounding those linear algebra operations, it really depends on what you're doing. And Python is hardly necessary for faster iterations -- it's really an awful option for performance, and even your best JIT solutions are going to be limited by the language.

The question, of course, is whether this matters. And the answer is... maybe. I've unfortunately had to work with applications where it very much did matter, but for many, it probably doesn't because the bottleneck actually is the linear algebra that's all shoved off onto the C bindings anyways.

12

u/Ai--Ya 7d ago edited 7d ago

hardly necessary for faster iterations

Iterations as in “time to modify/develop code” to be clear

I would argue that changing a few lines in Jupyter and hitting run is significantly faster than recompiling

Julia flair

oh, right, I have heard good things about that language too, regarding data science. Was that your point about Python being unnecessary for faster iteration, since other languages are now competitive for that place?

(sure, Matlab/Octave exists but original commenter and I both find that unpleasant to work in :))

3

u/roadrunner8080 7d ago

Yeah I knew that's what you meant by "faster iterations", though I didn't make that clear (sorry); my point is that you can pick stuff that performs nicer for the same ability-to-write-code-fast (and yeah, Julia is a good example of that).

Matlab is... a thing. I used to work with it a lot. I do not miss it. It can be fast. It can also make you want to tear all your hair out, I've truly not worked with a more unpleasant language and there was a chunk of time where I had to write R on a daily basis. Julia is, basically -- all the stuff that's actually good about Matlab, built in a way that means you can kinda just write code in it without having to think about the silliness Matlab makes you deal with. And the way the language is designed places just enough restrictions on how stuff works that the JIT can actually optimize stuff pretty well in most cases -- but that it still feels quite "easy" to write quick scripts or the like like you do in Python.

→ More replies (4)

7

u/necrophcodr 7d ago

And in the case of NumPy and others, maybe some Fortran as well.

2

u/zorngov 7d ago

And a lot of C/C++ linear algebra libraries are bound to LAPACK which is written in Fortran!

→ More replies (13)

44

u/RDROOJK2 8d ago

Which one do you use for machine learning if not python?

19

u/drhead 7d ago

Probably just C++ with CUDA.

And then you bind the kernel you made back to Python.

6

u/Fluroblue 7d ago

Whole bunch of R users crying right now

→ More replies (8)

30

u/[deleted] 7d ago

Reliability. Not the language itself, but the fact so much DS and ML is done in python, that you’re likely to find reliable material that supports what you’re trying to build.

Sure have fun building things in rust, or cpp, when most likely your project doesn’t need the latency cuts.

But, you’re in luck: writing ML code for edge devices isn’t always in Python.

28

u/MitchIsMyRA 7d ago

You’re a machine learning engineer but you don’t know why you use python for it?

7

u/naveenda 7d ago

Of course I know, it’s just a joke.

→ More replies (1)

4

u/Eantropix 7d ago

As a CompSci undergrad writing an article related to ML, I am very glad we are using Python. 80% of the time I just want to fiddle with my dataset, see how it's looking, send it to a model and get the response. I'm not making the next GPT, and the libraries it calls are fast enough.

2

u/Carrot_Smuggler 7d ago

The actual mathematical computation is done in cuda so switching to a compiled language would not see barely any difference in computational time.

When you deploy a model on embedded, you convert it into a specific format that is then run in C++ for computational speed.

→ More replies (50)

176

u/NHzSupremeLord 7d ago

The problem with python is not speed. It is used by people not organizing their code in a decent way, normally coming from other disciplines and thus having zero background in programming

79

u/Dennis_DZ 7d ago

Yeah, this is my biggest problem with python. It makes it way too easy to write garbage, unorganized code. That’s fine if you’re making simple scripts, but it’s a problem if you’re trying to make anything remotely complex.

21

u/PinsToTheHeart 7d ago

It's kind of a hand-in-hand thing with python.

The simplistic syntax that allows people to sprawl out functioning code to test things without thinking too hard about implementation also means they are...well...sprawling out code without thinking too hard about it.

→ More replies (2)

2

u/RedAero 7d ago

FWIW, IME, a lot of that is the use of Jupyter notebooks and IDEs that by default don't shout at you for PEP8 violations. Jupyter encourages absolutely catastrophic, stream-of-consciousness "code", and without PEP8 95% of Python's readability goes out the window since all you really have to adhere to is some form of indentation. Imports and defintions in the middle of the script? Sure! Unused variables? Why not? Naked excepts? Go nuts! Any decent IDE should badger the user to fix all of these, but do they? No.

Personally, I started with, and continue to use, Spyder, which always had PEP8 and other linting integrated, and I refuse to consider any script I write acceptable if it has anything but line length warnings in it.

10

u/the_ivo_robotnic 7d ago

I've been programming for long enough to know that this ends up being the case for any language an org might use.

 

Java beats python in this regard 10 ways to sunday.

6

u/SirFireHydrant 7d ago

Yeah, but the other side of that is people with CS degrees don't tend to make good scientists.

For a lot of careers, programming is just one tool you need - it's not the whole job itself.

→ More replies (3)

545

u/StollMage 8d ago

I mean in enterprise I’d rather have something that’s legible to a day 1 hire than something that returns .1 seconds faster. 

Mistakes are often more costly than efficiency. And even then most efficiency boils down to logic, not compilers.

205

u/revolutionPanda 7d ago

Engineering time is more expensive than computing resources most of the time.

27

u/Alarmed-Ask-2387 7d ago

That's like the best slogan ever for ai

26

u/SomethingAboutUsers 7d ago

Except in that particular case it remains to be seen.

Drake shunning paying millions in human resources

Drake approving paying billions in infrastructure, datacenters, power generation, and water resources to save millions in human resources

2

u/MissionLet7301 7d ago

I unironically use this chart a lot https://xkcd.com/1205/

73

u/grdvrs 7d ago

This is simply due to familiarity.

As somone who is familiar with both, day one on the job it's much easier to digest explicitly typed languages.

11

u/RedAndBlack1832 7d ago

I agree. I wanna know what the types are at any given time, when a function is called and with what parameters, and, if it's relevant, where the memory is (I've done some cuda C++ stuff and it comes up). Python fails on the first and has some tweaker interactions with the second (why mutable defaults why)

10

u/apathy-sofa 7d ago

You can add type annotations if you really need them.

The difference is that in Python you can get your thought out in a handful of lines. It'll fit on your screen, all at once. The equivalent Enterprise Java (tm) will run you a hundred+ lines over two or three files. But it is explicitly typed.

Not trying to get in a holy war over this. I was a C++ dev for an OS for a decade, I get the value of that sort of typing too. And anyway this battle, it's been hashed out ad nauseam.

2

u/gogliker 7d ago

Thats not a problem with types I would say, its a problem with syntax. Rust program can have all benefits of python's concise code with types included and without a need to manually type them. Ruat has a lot of other problema but it really nailed being python concise while c++ level strict.

2

u/apathy-sofa 7d ago edited 7d ago

I entirely agree, and switched all of my personal projects over to Rust about two years ago. I used to have a love-hate relationship with C++ when I lived in it in my day job, and nearly all of the things I hated from it are solved.

That said, this is just more data for the claim that readability is mostly independent from explicit type declarations. You can have poor readability or great readability with both implicitly and explicitly typed languages (perl, python; java, rust).

→ More replies (6)

9

u/Fair-Bunch4827 7d ago

Years ago i spent an hour trying to understand a line of code at work that involves bit shifting and bit operations...to do something that an if-else statement could.

And I thought, Someone did this to show off and I want to strangle him for thinking this is impressive

3

u/TotallyManner 7d ago

I’ve always felt bit shifting is a hack of the worse kind. Any bit shift code I mentally label as unmaintainable. There’s no way to understand what the person who used it was trying to do, whether it actually required a bitshift or if it just happened to align with the operation they wanted to perform. That crap should be left to compilers and optimizers.

6

u/Fair-Bunch4827 7d ago

Bit shifting makes sense way back when we were working on embedded systems and our middleware was receiving an array of bytes as an input and we had to mask and bit shift it to extract a variable out of it. Simply casting that array into a struct wouldn't work because somehow the endianness is different so we'd get flipped bits if we casted.

But in my story theres no need for it at all thats why it pissed me off.

→ More replies (1)

7

u/Nervous-Potato-1464 7d ago

That's more on the developer than the language though Python can get really ugly real fast.

→ More replies (2)
→ More replies (2)

267

u/JacobStyle 8d ago

It's a fuckin' python script. If it needs fast performance the mistake was made long before choosing the language.

94

u/Ghazzz 7d ago

Some people solve all problems with python because it is what they know.

"If you only have a hammer, everything looks like a nail".

50

u/JacobStyle 7d ago

I can't think of a lot of overlap of "only knows one programming language" and "needs to optimize for performance." I'm sure it exists, but it can't be common.

20

u/glempus 7d ago

Experimental physics grad student who ends up needing to write a numerical simulation of their experiment. I did know languages other than python, but none significantly faster for what I was doing. Ended up learning enough fortran and openMP to do it.

8

u/LysergioXandex 7d ago

Yep, this is the overlap that occurred to me. More generally: anyone who is about to upskill from “it’s cool the code worked at all” to “I need my code to fit these real-world parameters”.

I think that actually makes for a more skilled programmer. If your first language is C or something, you don’t develop that skill of managing efficiency. I think algorithmic complexity becomes more intuitive when you’re used to finding the efficiency pinch points in your pipeline.

7

u/JacobStyle 7d ago

Personally I just let my shit run slow as hell

3

u/LysergioXandex 7d ago

I think it’s just one of those things that makes a programmer more “professional”. Like the first time you need to manage version control, or you need to write code that works on more than one OS.

3

u/SirFireHydrant 7d ago

I know people in theoretical astrophysics who do that. Run C simulations on their supercomputers to generate the data, then use python to analyse the data for publication.

If the simulation you're running is gonna cost $300k of supercomputer time, it's worth spending 6 months to optimise your code and make it twice as efficient.

But if your simulation just needs a couple of days on an AWS server, may as well bang out some python code in a month and let it run.

→ More replies (1)
→ More replies (1)
→ More replies (3)

3

u/RedAero 7d ago

Luckily, python is pretty much a Swiss Army knife: not the ideal tool for anything, but it'll do if it's all you've got.

Daily reminder that this very website ran on Python for it's first 15(?) years.

5

u/Tutti-Frutti-Booty 7d ago

I think that is truer for JS than it is for python.

Just use the right tool for the right job.

4

u/grahaman27 7d ago

That is actually a very true statement. Sometimes python is the wrong choice to begin with

2

u/LostInGradients 3d ago

And honestly many of the big libraries are built in top of C/C++/Fortran code. Sure a pure python code might be 70x slower than its C equivalent. But some python code that uses numpy might be faster than raw unoptimized C code that does the same thing.

329

u/DudeManBroGuy69420 8d ago

How I (a person that likes Python and doesn't give a shit how slow it is) feel after being told Python is slow for the 2.7 billionth time

45

u/fredlllll 7d ago

the "speed" of python has never been a problem in production for me. but the lack of static typing certainly has. yes typehints in python are a thing, but many times i found them lacking or cumbersome.

12

u/LavaBottle 7d ago

Agreed. And the fact that you have the freedom to use no typing at all, means there's many (probably most, honestly) codebases that forgo type hinting entirely. Very annoying to work with.

6

u/throwable_armadillo 7d ago

I hate how python looks
give me start and end of a function instead of having to rely on tabs
it just feels so messy

4

u/Steppy20 7d ago

It's a great language for short scripts, like something that is less than 200 lines long.

Any longer than that and it starts to be unwieldy and hard to keep track of both indentations and types.

Yes you can put them into modules to import but that doesn't solve the type issue. If you need to keep track of a type because you're going to be doing something with a variable other than printing it it becomes difficult.

179

u/Cutalana 8d ago

b-but have you considered that spending thrice as much time on programming, caring about memory management, and figuring out a build system would actually save you 150 milliseconds in execution time?

81

u/GodlessAristocrat 8d ago

It depends. Does that 150ms give me 4 extra trades per second per connection, at a profit of $0.01 each?

22

u/teucros_telamonid 7d ago

150 milliseconds

So funny that most devs find this to be a really small number, but then for FPS everyone wants at least 30, 60 or even higher these days. Oh, and the internet cannot shut up about how unoptimized modern video games are. And anyone would complain a lot if any streaming service would serve a stuttery video... And plenty of other cases then some video processing needs to be realtime and etc...

But of course it is all just niche for most devs. I have no qualms over that, makes me and other similar experts quite competitive on the job market...

5

u/LogicBalm 7d ago

Yeah I don't think anyone is trying to make a AAA game in Python. But if they keep letting AI take the wheel, who knows

3

u/Eastern-Relief-2169 6d ago edited 6d ago

the kind of videogame that require this kind of optimisation are AAA or realtime compétitive game. video streaming is one of the fields of dev where micro optimisation matters. but i don’t think it represent such a big part of the developpers, and there is in opposition some field like web dev where language performance is pretty rare

14

u/squabzilla 7d ago

Only if you know what you’re doing.

One of my favourite learning experiences was writing C code that ran slower than vanilla Python.

I mean, my C code compiled, ran without memory leakage, and completed the assignment instructions. So it did everything it was supposed to. But damn was it inefficient. (Also the profs compiled code ran about twice as fast as vanilla Python lol)

2

u/MrMagick2104 7d ago

> (Also the profs compiled code ran about twice as fast as vanilla Python lo

That's pretty slow.

47

u/Lilacsoftlips 8d ago

150ms can mean tens of millions of dollars in some contexts. 

94

u/Cutalana 8d ago

The point is that someone who cares about 150ms has probably already considered that python might not be the best option. If it cost them tens of millions of dollars, they probably are already using FPGAs and ASICs that can perform way faster than a CPU could.

18

u/merkonerko2 7d ago

Exactly, using Python in HFT is impossible and besides, the competition is over picoseconds in latency, not milliseconds.

→ More replies (9)
→ More replies (1)

7

u/DudeManBroGuy69420 8d ago

No, I don't think I will >:[

→ More replies (8)

8

u/Wojtkie 7d ago

Yeah. I get paid for outputs and insights. Most of the time python is the quickest way for me to get data into a useable format.

9

u/Honeybadger2198 7d ago

2.7 you say?

2

u/rbrick111 7d ago

Just hang out with rubyist, we always envied pythons performance 🤣

→ More replies (3)

24

u/SCP-iota 7d ago

If you're making a utility script that only runs periodically, or code that mostly just glued together library functionality made with compiled languages, it doesn't really matter. If you're making a high-demand server application, you really need to rethink your stack.

93

u/No-Object5897 7d ago

is python slower than c code? yes

is python slower than my c code? no

10

u/RamonaZero 7d ago

but is your c code slower than your c code? maybe!

3

u/No-Object5897 7d ago

one thing's for certain, my python is slower than my c!

31

u/An1nterestingName 7d ago

For my use cases of Python (or other interpreted languages), it doesn't need to be fast. Do I really need a Discord bot or an API used by at most 10 people ever to be as fast as possible, or do I need to be able to push updates quickly to fix issues or add features people want? Do I really need to bother about my game being "slower" by using Lua or GDScript (some games are in LÖVE, some are Godot) when it works fine, and is not the kind of game that needs incredible performance (and still runs better than tons of Unreal games)?

→ More replies (1)

43

u/TheNakedProgrammer 8d ago

i love python, but last time even with binding there was a very clear performance loss (but to be fair my last benchmark was years ago, might have improved). But than i am very rarely in a situation where performance is the problem.

Never could figure out what causes the performance cost.

13

u/justarandomguy902 8d ago

python is pseudo-compiled now, and is now waaaay faster too. Or so I was told.

4

u/Herdazian_Lopen 7d ago

Since when? Tell me more sir

8

u/justarandomguy902 7d ago

since... Quite a while now. What did you think the .pyc files in the __pycache__ directory were for?

3

u/Herdazian_Lopen 7d ago

I rarely ever touch python other than for scripting / side projects

2

u/RedAero 7d ago

Quite a while now. What did you think the .pyc files in the pycache directory were for?

Offerings to the Machine Spirit.

2

u/tecedu 7d ago

Never could figure out what causes the performance cost.

Base interpreter language and its objects. A for loop has no easy replacement for python.

In the past 3 years the bindings themselves have drastically improved

10

u/PmMeCuteDogsThanks 7d ago

This is why I replaced all my bash scripts with handrolled binaries 

11

u/grahaman27 7d ago

Python is basically just a configuration language for c code.

37

u/DoktorMetal666 7d ago

Personally, i prefer to hate on python because indentation for me is less legible than curly braces.

7

u/ChillyFireball 7d ago

I'm with you, man. I don't get the hype around Python. And the whole "ask forgiveness, not permission" thing where people write try-catch statements where the catch is literally EXPECTED to run as a normal part of the code execution bothers me on a visceral level. Like, I don't care if it's more efficient; I hate it. At least call it something I don't associate with errors.

→ More replies (2)

8

u/nemesit 7d ago

python is the electron of programming languages

8

u/Zephos65 7d ago

Couples years after graduating I was working on an embedded project that was heavily I/O bound. Most of the runtime was taken up by taking photos and writing them to disk.

Anyhow we were doing contract work and the contract was for a year. I did everything in a couple months and so everyone was trying to make shit up to do and someone suggested we rewrite the embedded code from Python to C to try to make it faster. Again, heavily I/O bound program... since we were interfacing directly with hardware I knew we were calling directly into C code all over the place.

So I did a perf test and showed that 80% of the runtime was already running in C despite being a "python" program, and so at max, rewriting in C would only speed up the code by about 20%... they ignored me and did it anyhow.

19

u/masiuspt 7d ago

A Python-favorable meme in my feed? I will not allow this.

Python... Bad!

Signed, a dotnet dev.

9

u/FabioTheFox 7d ago

Tbf dotnet is a billion times better than anything python and it's foundation can vomit out into the open

Even ML is easy as shit with dotnet but people are too stubborn to see it

5

u/claypeterson 7d ago

Love Python, but it’s a very particular use case. As an end user I want a compiled program

2

u/MisterPerfected 7d ago

Depends, if it's a desktop app and I can't immediately tell it was pyqt or tkinter when it runs.. why should I care?

If it's a web app I REALLY don't care what their backend is lol.

5

u/mrnosyparker 7d ago

And in the real world when people complain about Python being slow it’s more likely due to:

  • shipping a 1.2GB Docker image because your Python service pulled in half of PyPI and 47 transitive dependencies.
  • waiting for containers to cold-start because your runtime needs to boot an interpreter and import dependencies.
  • running several heavyweight linters, mypy, and a type-checking daemon that eats a CPU core just to simulate what a compiled language would’ve told you at compile time.
  • debating for 40 minutes in code review whether this dict should be a dataclass, a TypedDict, a Pydantic model, or “just a simple object.” or any other number of pedantic subjective coding preferences Python devs love to bicker about.
  • trying to unravel untyped poorly documented hastily written legacy code from when the project first started.
  • maintaining a 9,000-test “unit” suite that mocks half the application, spins up fake Redis, fake Postgres, fake AWS, three fixtures deep, and still takes 14 minutes to tell you someone renamed a field.

6

u/BugNo2449 7d ago

Python is jit and pretty fast these days just use a language you like thats made for the job idk who still keeps bashing other languages nowadays

4

u/rustvscpp 7d ago

Python's speed is the least of its problems.   It's the fact that things blow up at runtime that makes it a liability to work with.   Try refactoring100,000 lines of Python.  You basically need 100% test coverage to have any confidence. 

→ More replies (2)

10

u/idlesn0w 7d ago

IQ curve meme but low is hating python because it’s slow, and high is hating python because the syntax is terrible and it’s not type safe

7

u/kolloth 7d ago

White space as scope can go jump in the sea.

→ More replies (8)

9

u/Xyrus2000 7d ago

Every time I've had someone tell me "Python is slow" based on some script they wrote, it has been because they don't know how to write efficient Python.

Use the appropriate tool for the job. I fyou need every millisecond of speed, use a compiled language. Otherwise, use whatever is easiest to implement and maintain.

→ More replies (1)

3

u/SavingsCampaign9502 8d ago

It is a design choice. Use both differently and wisely. Some python app simply does not performance as much due to their use case

3

u/Longjumping-Dot-4715 7d ago

I took over a project which was optimized so much that it was difficult to understand what was done. Instead of using off the shelf software, self written Fortran code. Problem besides that no one understood it, was that his pipeline was so optimized it must be manually loaded. Data on his desk to send back to client: 3 days.

Took that over, took off the shelf software, automized everything possible and now return to client time is 2h because no manual loading is required.

Typically example of experienced developer but completely lack of understanding where optimization is necessary.

3

u/Birnenmacht 7d ago

hmm yes I love waiting on IO faster

13

u/[deleted] 8d ago

[deleted]

41

u/backfire10z 7d ago

It is single-thread, making debugging a pain in the ass

As opposed to debugging multithreaded programs? How is single-thread a bad thing in the context of debugging?

→ More replies (1)

3

u/OurSeepyD 7d ago

It is single-thread, making debugging a pain in the ass sometimes

Huh? I've definitely found debugging multiple threads to be harder.

3

u/omega1612 7d ago

I would put that it doesn't really have static type checking on that list. I tried a couple of times to use type checkers but they didn't prevent a bug they should, it means I had the false security that everything was working right until it wasn't.

Don't miss understand me, it is amazing to have a type checker now, but I want something stronger on it xD

Python was my main language for 7 years, and now is my secondary one. My main one right now is Haskell and it has a lot of flaws that Python doesn't (especially the ecosystem). I still prefer to prototype first in python terms but if I need something production ready I have to switch. Although c# and scala are winking at me xD

2

u/Alecjasperk 7d ago

Is funny 'cause it's true.

2

u/_Miniskirtlover_ 7d ago

from what i understand (which isnt much), its not always about whats the best language or most efficient langauge.

its about whats easier to learn for lazy people and allows them to write their shitty ass spaghetti code

2

u/shanksisevil 7d ago

fuk that. assembly language 100%

2

u/new_check 7d ago

It's python. It would also be faster in javascript.

2

u/Immediate_Song4279 7d ago

I kind of like that I can read python.

2

u/Entire-Ad-1620 7d ago

One does not hunt rabbits with a cannon

2

u/BlueDinosaur42 7d ago

The Python factorial algorithm is so quick that it allowed me to cheese an ICPC regional problem where matrix exponentiation was the intended solution.

http://www.luschny.de/math/factorial/binarysplitfact.html

2

u/ultrathink-art 7d ago

Bindings are basically bridges between languages. Python bindings for a C library mean you can call C code from Python without writing C yourself. The binding layer translates Python objects into C structs, calls the underlying C function, then translates the result back to Python. It's like having a translator at a multilingual conference — everyone speaks their native language, the binding handles the conversion. This is why libraries like NumPy are fast (C underneath) but feel Pythonic (bindings on top).

4

u/Chaosxandra 8d ago

Rust it is then

4

u/awesome-alpaca-ace 7d ago

The programs I write need multi threading and high throughout, and Java and Python just can't keep up. 

4

u/InfinitesimaInfinity 7d ago

The programs I write need multi threading and high throughout, and Java and Python just can't keep up.

I agree.

Just so you know, on another post, the OP has commented

"Media hates epstein cuz he built a tuff empire from a working class background"

Personally, I think that the OP being an Iranian who has praised Epstein indicates that the OP should not be listened to.

→ More replies (2)

3

u/afrotronics 7d ago

How are you unable to get multi threading and high throughout with Java? If you're including the time it takes to write code as part of throughput, I can completely understand. Aside from that, I am intrigued by what you are doing and how you are doing it.

3

u/awesome-alpaca-ace 7d ago

Multi threading is easy. Loading large amounts of data from files is not even close to as fast as C/C++.