408
all 30 comments
sorted by: hot top controversial new old
[-] Hazel@lemmygrad.ml 2 points 1 day ago

comrade numpy o7

[-] communism@lemmy.ml 116 points 6 days ago

I like my memes to come with a bibliography.

[-] alsaaas@lemmy.dbzer0.com 9 points 5 days ago
[-] CanadaPlus@lemmy.sdf.org 5 points 5 days ago* (last edited 5 days ago)

Okay, now do it by percent of processor (CPU/GPU/whatever) cycles.

Although, TBF, you can replace it all with C/C++. Or Rust, assume the optimisation has gotten good enough. It's just that few people are both qualified for and interested in rewriting numerical linear algebra algorithms, and there's no real reason to if the Fortran works.

[-] tetris11@lemmy.ml 32 points 6 days ago

When you download R, youre downloading C++/C and Fortran

[-] TimeSquirrel@kbin.melroy.org 21 points 6 days ago

Everything is just silicon oxide gates being saturated and drained and turned on and off in various patterns very rapidly in a way that means something to us. That Fortran/C/C++/Assembly depends on that tiny two-MOSFET AND gate in the ALU to do the AND correctly every time.

Programming languages at the basic level are just an automated way of putting numbers into a calculator, processing them, and getting another number/status/flag back and doing something else with it based on the result.

[-] isolatedscotch@discuss.tchncs.de 11 points 6 days ago

meanwhile, me trying to get a feeling for how fast A GHz is by waving my arm as fast as I can:

[-] milkisklim@lemm.ee 14 points 6 days ago

Well I be damned. What does the Fortran do ?

[-] BartyDeCanter@lemmy.sdf.org 35 points 6 days ago

Array operations in FORTRAN are much easier for the compiler heavily optimize than it is in c/c++ due to its array model and type system. You can achieve much of the same thing with modern compiler extensions, but it’s difficult and not as portable.

[-] milkisklim@lemm.ee 7 points 6 days ago

That's interesting, thanks

[-] tetris11@lemmy.ml 14 points 6 days ago

Its just easy to write super-optimised code snippets in without having to break out into assembly.

[-] recursiveInsurgent@lemm.ee 4 points 6 days ago

What is the reason to avoid assembly? Is it prohibitively difficult?

[-] dewritoninja@pawb.social 10 points 6 days ago

Not only is it very difficult to write in assembly, the resulting code is not portable. Meaning that if you wrote it on x86 assembly it can't run on ARM chips without emulation and that takes a significant hit on performance defeating the point

[-] SqueakyBeaver@lemmy.blahaj.zone 8 points 6 days ago

Yeah, it's pretty difficult. Think of assembly as just one step above writing 1's and 0's, and you're probably around how difficult it can be

[-] recursiveInsurgent@lemm.ee 8 points 6 days ago

I’ve delved into writing assembly only on the level of a student project. I really enjoyed it though. Obviously implementing a python math library would be far more complex but wouldn’t it be worth it for the possible performance gains?

[-] JackRiddle@sh.itjust.works 10 points 6 days ago

I don't think it would be anymore. Modern compilers are really really good at what they do, and often manually optimizing(writing assembly yourself) makes programs slower. So unless you are very good at assembly, I would just trust the compiler.

[-] HStone32@lemmy.world 3 points 5 days ago

I'll never understand why my classmates prefer python to R.

[-] Chais@sh.itjust.works 1 points 3 days ago

Because R is incredibly clunky. I've worked with both and never got the hang of R.

[-] HStone32@lemmy.world 1 points 3 days ago* (last edited 3 days ago)
import numpy as np

temp = np.array([22, 21, 25, 23])
sd_temp = np.std(temp, ddof=1)
print(sd_temp)

Vs

temp <- c(22, 21, 25, 23)
sd(temp)

How in the world is R more clunky than python?

Edit: and I didn't even mention how python likes to break unrelated software packages whenever I'm forced to use it.

[-] abraham_linksys@sh.itjust.works 4 points 6 days ago
[-] DannyBoy@sh.itjust.works 14 points 6 days ago

What does it say under the Languages section for that repo?

[-] abraham_linksys@sh.itjust.works 8 points 6 days ago

That I need to quit posting drunk because I can't read obvious shit

[-] DannyBoy@sh.itjust.works 4 points 6 days ago

Hope you're feeling okay this morning Mr. Linksys, I love your username!

[-] weker01@sh.itjust.works 7 points 6 days ago

Numpy can use BLAS packages that are partly written in Fortran

[-] joshcodes@programming.dev 11 points 6 days ago

It provides:

  • a powerful N-dimensional array object
  • sophisticated (broadcasting) functions
  • tools for integrating C/C++ and Fortran code
  • useful linear algebra, Fourier transform, and random number capabilities

Not according to the repo I sourced from your message.

[-] 4am@lemm.ee 5 points 6 days ago* (last edited 6 days ago)

“Tools for integrating” is not “written in”, try again

“* A Fortran compiler is needed only for running the f2py tests. The instructions below include a Fortran compiler, however you can safely leave it out.” from https://numpy.org/devdocs/building/index.html#building-from-source

[-] joshcodes@programming.dev 3 points 5 days ago

Yeah look that was the front page of the repo talking about how it has C/C++ and Fortran code, sorry for not reading the docs and finding out that yes they still use C/C++ and Fortran code in the form of OpenBLAS which is a dependency... f2py is just a method of doing the following:

F2PY facilitates creating/building native Python C/API extension modules that make it possible

  • to call Fortran 77/90/95 external subroutines and >Fortran 90/95 module subroutines as well as C functions;

  • to access Fortran 77 COMMON blocks and Fortran 90/95 module data, including allocatable arrays

from Python.

Correct me if I'm wrong here but if you're implementing an api for one programming language to talk to another then that means you have 2 programm-

I wake up as a lizard. The meaning of kernels, subroutines and programming languages is already fading. I realise the rock I am lying on is slightly in a shadow and move into the sun. Might eat a bug later...

this post was submitted on 15 Feb 2025
408 points (98.8% liked)

Programmer Humor

32707 readers
136 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS