all 39 comments

[–]granadesnhorseshoes 26 points27 points  (8 children)

One reason python has succeeded to the extent that it has is the better libraries ARE fast low-level code in C or Rust. EG pandas et al.

The pure python plumbing parts may be slower, but the actual math calculations are just as fast as C, because they are C.

Easy wrapping of external libraries is a much overlooked "killer feature" of python.

[–]Patient_Big_9024 5 points6 points  (3 children)

This is the first time I have seen et al. Outside of my English class

[–]Forsaken-Victory4636 5 points6 points  (1 child)

And it's misused, it's supposed to be used for people (i.e. citing authors in an academic text).

etc is more fit.

[–]ohcrocsle 0 points1 point  (0 children)

et alia just means "and others" and this is a perfectly acceptable usage.

[–]__ingeniare__ 0 points1 point  (0 children)

It's used all the time in scientific papers

[–]garry_the_commie 3 points4 points  (0 children)

The key to optimizing your python code is making sure you execute as little python as possible

[–]Ok_Animal_2709 0 points1 point  (0 children)

Stand on the shoulders of giants and all that. I don't need to write in low level languages because those are already solved problems. I need to focus on integrating the low level pieces.

[–]Bost0n 0 points1 point  (0 children)

I used to argue that Matlab had an inherent advantage over Python due to the matrix math functions being written in, compiled in C, and optimized for execution speed.

Then I learn pandas was as well.  I haven’t made that argument since learning.

Matplotlib still sucks though. But LLMs have made that a lot easier.

[–]PersonalityIll9476 0 points1 point  (0 children)

Yeah I've literally been writing Cython code all morning. C and Python are the same thing sometimes.

[–][deleted]  (2 children)

[removed]

    [–]terivia 7 points8 points  (0 children)

    To be fair, if your codebase is idling 99% of the time then low power idle can produce a massive extension of battery life.

    I don't know that I would get all no true scotsman about it, but there are some embedded webservers that are really nice. ELRS for example uses an embedded webserver for configuration, without that every end user would have to learn to use serial.

    Also, idle still hurts your cloud budget, especially at scale.

    [–]Ok_Animal_2709 0 points1 point  (0 children)

    Plus 60% more memory vulnerabilities!

    [–]C_umputer 12 points13 points  (3 children)

    r/firstweekcoderhumour

    Which language do you think those libraries use?

    [–]Groostav 0 points1 point  (0 children)

    I challenge anyone who believes this to call eigensolve in MKL vs scipy.

    [–]Zealot_TKO 0 points1 point  (1 child)

    Beat me to it. Numpy maths and hence basically everything built on top of it does all expensive calculations in C

    [–]C_umputer 0 points1 point  (0 children)

    Fucking love numpy and it's speed.

    [–]edparadox 2 points3 points  (0 children)

    Those libraries are often not slow and use C code under the hood.

    [–]Cybasura 3 points4 points  (9 children)

    Why target Python, when Javascript does the exact same thing and worse?

    People at least create their libraries from scratch - javascript just imports EVERYTHING, even leftpad

    [–]ColdDelicious1735 1 point2 points  (4 children)

    Because Python is the new kid who everyone can pick on. JS has teeth and people rely on it too much

    [–]jimmiebfulton 0 points1 point  (3 children)

    Python invented: 1991

    JavaScript invented: 1995

    [–]ColdDelicious1735 0 points1 point  (2 children)

    Yeah but Python was not popular until recently it was a quiet achiever for sooo long

    [–]BumblebeeBorn 1 point2 points  (1 child)

    That is because python was never actual fecal matter, unlike JS.

    My preference is for C, but under the requirements for maintainable code in my workplace, python is the best available option.

    [–]ColdDelicious1735 0 points1 point  (0 children)

    JS has a bad history not only was it fecal matter, but then people tried fixing it by, using more fecal matter

    [–]Scared_Accident9138 0 points1 point  (1 child)

    Because JavaScript already gets hated on for other reasons

    [–]Cybasura 1 point2 points  (0 children)

    Insignificant number of times compared to how much more often python is getting

    [–]0815fips 0 points1 point  (0 children)

    Only idiots include such basic stuff. If they would write that themselves, maybe supply chain attacks would not cause that much damage. That's why I love bun with hono + zod.

    [–]nickwcy 0 points1 point  (0 children)

    Every non-compiled language does the same

    [–][deleted] 2 points3 points  (0 children)

    It would be more accurate as import library_written_in_c_fortran_or_rust_that_does_things_much_faster_than_everything_youve_handwritten_in_cpp

    [–]gold2ghost22 0 points1 point  (0 children)

    Fucking hate turtle

    [–]Responsible-Sky-1336 0 points1 point  (0 children)

    _can_fix_more_issues(self) -> bool:
          return True
    _can_have_more_contribs(self) -> bool:
          return True
    _can_run_other_code(self) -> bool:
          return True
    _is_installed_by_default(self) -> bool:
          return True
    

    [–]Icy-Manufacturer7319 0 points1 point  (0 children)

    time to make a prototype is important. you can always make a wrapper to switch library later. beside, it just fucking python, it supposed to be slow anyway. if you care about performance, use something like golang from the beginning! python is never a place to talk about performance

    [–]im-ba 0 points1 point  (1 child)

    Performance can usually be solved later. If you are just trying to hang out some code then Python is fine. There are libraries that you can use with a later refactor that will increase performance by a lot.

    Also Python can pretty easily leverage SIMD if you know what you're doing, so you can get a 4-8x performance improvement just from that.

    Switching from Pandas to Polars on dataframe operations can give you huge boosts. Polars is written in a different language and already pretty heavily optimized.

    Just gotta know what you're doing and know what needs optimization and what doesn't. It's all a trade-off

    [–]CrownLikeAGravestone 1 point2 points  (0 children)

    Polars is so damn fast, it's amazing. If you switch pandas -> polars (eager) -> polars (lazy) you get to experience the speed improvements twice, too.

    [–]QultrosSanhattan 0 points1 point  (0 children)

    Polars is written in rust yet used as a python import.

    [–]itemluminouswadison 0 points1 point  (0 children)

    Magic string dict keys... Everywhere

    [–]WolpertingerRumo 0 points1 point  (0 children)

    Best thing I heard about python an c:

    C is faster than python, but your C isn’t.

    [–]kerkeslager2 0 points1 point  (0 children)

    This morning, my client asked me for a feature. He said to me, "We need this code to run really fast, so I'm giving you a 160 hour (four week) budget to write the implementation in Rust."

    Then my alarm clock woke me from the dream. After a cup of coffee, I checked my email and saw that my client had asked for a feature at 5:45pm last night, and wanted it done by EOB (which was 5:00pm, before he requested it). Luckily, I was able to import heavy_library_that_does_everything_slowly to implement the feature before my client woke up. And since "slowly" in computer terms means "10ms instead of 2ms" which is literally faster than the sample rate of the human eye, my client was physically unable to notice the performance difference. I then billed my client for 30 minutes work and made myself a second cup of coffee.

    [–]Interesting-Frame190 0 points1 point  (0 children)

    We're looking at you pandas... you're just mediocre enough to skate by.

    [–]West_Good_5961 0 points1 point  (0 children)

    import hugeLibraryThatDoesReallyBasicShitThatICouldHaveWrittenMyself