News for hackers. Stuff that matters.
Re:CPython Internals Explained by damjon on Saturday January 31, 2026 @12:02PM (#46838375)
I've been comparing various platforms and discussing them with ChatGPT—for instance, why Python's execution is slower than JavaScript's V8. It claimed this is due to mtechnical debt and the inability to change because libraries like NumPy bypass public interfaces and access data directly.

I'm wondering how much of that is true and what is just a hallucination."

Btw: JavaScript seems to have similar complexity issues.

Edit: Python has no JIT

Re:CPython Internals Explained by g947o on Saturday January 31, 2026 @12:15PM (#46838530)
As someone who has many times dived into deep rabbit holes like this (e.g. how does JavaScript's prototype-based class work?), some effective ways to handle this is to ask follow up questions, use web search or ask for references. Deep search also helps. Often it corrects itself or takes back claims that have no basis. At the very least, it provides references that you can read yourself.

Of course, you can't really do all of that on a free plan.

That's far from ideal, but if you are motivated and care about these technical details (which you probably do), you can get pretty good results.

=====

Putting all of this aside, you can sometimes find YouTube videos on obscure channels that talk about these things. Chances are that someone who cares to make a YouTube video about these hardcore topics know what they are talking.

Re:CPython Internals Explained by hmry on Saturday January 31, 2026 @12:14PM (#46838519)
> Edit: Python has no JIT

In 3.14 and up you can enable JIT by setting the env var PYTHON_JIT=1

Re:CPython Internals Explained by brcmthrowaway on Saturday January 31, 2026 @01:04PM (#46838985)
Who made this JIT? FAcebook?
Re:CPython Internals Explained by hmry on Saturday January 31, 2026 @02:07PM (#46839689)
Lots of people. Several people from Arm and Microsoft, various PhD students... I don't know if anyone working at Facebook worked on the JIT, maybe they did.
Re:CPython Internals Explained by simonw on Sunday February 01, 2026 @05:39AM (#46845149)
Facebook engineers (most notably Sam Gross) contributed a lot of the no-GIL work: https://lwn.net/Articles/939981/

Much of the initial work on the JIT came from Microsoft's Faster CPython team: https://lwn.net/Articles/1029307/

Re:CPython Internals Explained by ayhanfuat on Saturday January 31, 2026 @12:09PM (#46838457)
It is not that numpy bypasses public interfaces. It uses documented C APIs. V8, as far as I know, does not have that.
Re:CPython Internals Explained by wk_end on Saturday January 31, 2026 @12:14PM (#46838520)
V8 itself might not, but, say, Node does and that doesn't torpedo performance. Was Node-API just better designed than Python's FFI?
Re:CPython Internals Explained by kccqzy on Saturday January 31, 2026 @06:11PM (#46841866)
My understanding is that Node still doesn’t give you low-level C APIs into the language itself. It gives you JavaScript APIs that call into I/O libraries (libuv basically).

Python it’s not hard to write a module in pure C that manipulates other Python objects. This means the representation of Python objects has to be stable enough for the C code. V8 does not allow that.

Re:CPython Internals Explained by wk_end on Sunday February 01, 2026 @02:30AM (#46844276)
I haven’t tried it myself but I don’t think that’s the case. See the documentation here:

https://nodejs.org/api/n-api.html

I’ve only skimmed this, but it sure sounds like it lets you write C code that operates on JS objects. In fact, it explicitly says “APIs exposed by Node-API are generally used to create and manipulate JavaScript values.”

Re:CPython Internals Explained by johndough on Saturday January 31, 2026 @12:34PM (#46838715)

    > Edit: Python has no JIT
There are quite a few JITs:

JIT-compiler for Python https://pypy.org/

Python enhancement proposal for JIT in CPython https://peps.python.org/pep-0744/

And there are several JIT-compilers for various subsets of Python, usually with focus on numerical code and often with GPU support, for example

Numba https://numba.pydata.org/numba-doc/dev/user/jit.html

Taichi Lang https://github.com/taichi-dev/taichi

Re:CPython Internals Explained by davepeck on Saturday January 31, 2026 @01:31PM (#46839260)
Per PEP 744, cpython shipped with an experimental JIT (default disabled) in 3.13. It remains experimental in 3.14.

See https://docs.python.org/3/whatsnew/3.13.html#an-experimental...

Re:CPython Internals Explained by gf000 on Saturday January 31, 2026 @01:08PM (#46839026)
If we are being very pedantic, languages don't have "speed", only implementations do.

Of course in the real life there are de facto implementations and language features give way to better/worse tradeoffs.

With that out of the way, Python is basically the de facto glue language. It is very often used to provide a scripting API over lower level C libraries. To be ergonomic in this function, CPython (the major implementation) exposed some internal details of its execution model, which C libraries can reach into. This makes it very hard to make more aggressive optimizations, as one example a C library can just increase/decrease the reference count of an object. Another design decision (that got some discussion recently) is the GIL (global interpreter lock) that makes python much less competitive than something like Java. (JS also does a single thread of execution, though there are ways around it).

JS has a different use case, so access to the C world doesn't impose such restrictions on it.

Re:CPython Internals Explained by mkoubaa on Saturday January 31, 2026 @02:06PM (#46839682)
Both you and the grandparent comment are correct. The implementation is slow because the API that it exposes is so leaky that implementation changes (for example a tracing garbage collector) are impossible to implement without changing the API, and the API cannot easily change because of the dependence or the ecosystem on it (e.g. numpy)
Re:CPython Internals Explained by palata on Saturday January 31, 2026 @05:21PM (#46841484)
For what it's worth, I really don't get the downvotes. I think it is an interesting question, and it brought interesting answers.

No clue if that's the reason for the downvotes, but maybe next time don't mention ChatGPT and just formulate this as "From what I read, [...]".