this post was submitted on 12 Apr 2025
195 points (90.1% liked)

Technology

69211 readers
3332 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related news or articles.
  3. Be excellent to each other!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, this includes using AI responses and summaries. To ask if your bot can be added please contact a mod.
  9. Check for duplicates before posting, duplicates may be removed
  10. Accounts 7 days and younger will have their posts automatically removed.

Approved Bots


founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] PattyMcB@lemmy.world 5 points 1 week ago (4 children)

I appreciate the large amount of info. Great answer. It just doesn't make sense to me, all things being equal (including performant algorithms), why choose Python and then make a small performance tweak like in the article? I understand preferring the faster implementation, but it seems to me like waxing your car to reduce wind resistance to make it go faster, when installing a turbo-charger would be much more effective.

[–] Teanut@lemmy.world 16 points 1 week ago

If you use the profiler and see that the slower operation is being used frequently, and is taking up a chunk of time deemed significant, why not swap it to the faster version?

In a simulation I'm working on that goes through 42 million rounds I spent some time profiling and going through the code that was eating up a lot of time (especially things executed all 42 million times) and trying to find some optimizations. Brought the run time down from about 10 minutes to 5 minutes.

I certainly wasn't going to start over in C++ or Rust, and if I'd started with either of those languages I would have missed out on a lot of really strong Python libraries and probably spent more time coding rather than refining the simulation.

[–] lengau@midwest.social 9 points 1 week ago (1 children)

I think a better analogy would be that you're tuning your bike for better performance because the trade-offs of switching to a car are worse than keeping the bike.

[–] PattyMcB@lemmy.world 5 points 1 week ago (1 children)
[–] Azzu@lemm.ee 5 points 1 week ago

Good, more people should buy bicycles

[–] 0ops@lemm.ee 1 points 1 week ago

If anything, to me it seems more important for a slower language to be optimized. Ideally everything would be perfectly optimized, but over-optimization is a thing: making optimizations that aren't economical. Even though c is many times faster than python, for many projects it's fast enough that it makes no practical difference to the user. They're not going to bitch about a function taking 0.1 seconds to execute instead of 0.001, but they might start to care when that becomes 100 seconds vs 1. As the program becomes more time intensive to run, the python code is going to hit that threshold where the user starts to notice before c, so economically, the python would need to be optimized first.

[–] orcrist@lemm.ee 1 points 1 week ago

It is a small performance tweak if done once, right? But let's suppose people worried about refactoring here would have checked to see what areas of their code are seeing heavy use.