News for hackers. Stuff that matters.
Re:Python Numbers Every Programmer Should Know by Scubabear68 on Thursday January 01, 2026 @06:21PM (#46459336)
No.

Python’s issue is that it is incredibly slow in use cases that surprise average developers. It is incredibly slow at very basic stuff, like calling a function or accessing a dictionary.

If Python didn’t have such an enormous number of popular C and C++ based libraries it would not be here. It was saved by Numpy etc etc.

Re:Python Numbers Every Programmer Should Know by dnautics on Thursday January 01, 2026 @11:02PM (#46461276)
i hate python but if your bottleneck is that sqlite query, optimizing a handful of addition operations is a wash. thats why you need to at least have a feel for these tables
Re:Python Numbers Every Programmer Should Know by aragilar on Friday January 02, 2026 @06:11AM (#46463669)
I'm not sure how Python can be described as "saved" by numpy et al., when the numerical Python ecosystem was there near the beginning, and the language and ecosystem have co-evolved? Why didn't Perl (with PDL), R or Ruby (or even php) succeed in the same way?
Re:Python Numbers Every Programmer Should Know by HenriTEL on Friday January 02, 2026 @07:12AM (#46464030)
22ns for a function call and dictionary key lookup, that's actually surprisingly fast.
Re:Python Numbers Every Programmer Should Know by mrguyorama on Friday January 02, 2026 @01:55PM (#46468073)
In that time the java app parsed 50 strings for object hierarchies (using a regex that isn't cached) and extracted values from a request object to a processing object, handled errors, and logged results.

3 times.

This is the naive version of that code, because "I will parallelize it later" and I was just getting the logic down.

Turns out, when you use programming languages that are fit for purpose, you don't have to obsess over every function call, because computers are fast.

I think people vastly underestimate how slow python is.

We are rebuilding an internal service in Java, going from python, and our half assed first attempts are over ten times faster, no engineering required, exactly because python takes forever just to call a function. The python version was dead, and would never get any faster without radical rebuilds and massive changes anyway.

It takes python 19ns to add two integers. Your CPU does it in about 0.3 ns..... in 2004.

That those ints take 28 bytes each to hold in memory is probably why the new Java version of the service takes 1/10th the memory as well.

Re:Python Numbers Every Programmer Should Know by HenriTEL on Saturday January 03, 2026 @05:54AM (#46475168)
Python is slow but in my experience (that mostly relates to web services and data processing) I found that I/O was by far the biggest bottleneck. Waiting for the database, another http service or local storage, which often takes more than 1ms anyway.
Re:Python Numbers Every Programmer Should Know by Scubabear68 on Saturday January 03, 2026 @11:19AM (#46478370)
Yep.

Except when it’s not I/O.

Re:Python Numbers Every Programmer Should Know by igiveup on Saturday January 03, 2026 @03:08PM (#46481004)
22ns might be about 100 processor instructions. Somehow I doubt that any programming language can parse 50 strings in 100 instructions, let alone with naive code.
Re:Python Numbers Every Programmer Should Know by mrguyorama on Monday January 05, 2026 @11:22AM (#46500684)
You are right.

I have said something very wrong. Java may be fast but it isn't magic.

What I claimed is not possible and I should have realized that.

I can not correct my previous claim. I wish HN had longer edit windows and I wish HN allowed you to downvote older comments.

I cannot erase this wrong info