r/ProgrammerHumor • • 5d ago

Meme pythonSlow

Post image
11k Upvotes

413 comments sorted by

View all comments

Show parent comment

31

u/FalafelSnorlax 5d ago

Yeah but isn't a lower-level language, it's a machine-friendly format of the language. The main point is that by virtue of being interpreted, it is inherently different to languages like C/C++ or Rust.

12

u/toejam316 5d ago

Inherently whatever the code is at some point "compiles" into the language the CPU uses. The fact it's running in a JIT interpreter doesn't prevent that. If you were insane enough you could absolutely get the assembly equivalent of your python code.

3

u/m0nk37 4d ago

Python loads the C/C++ library that runs the machine learning, python listens for events from the library and delivers it to you. Thats what a wrapper is, there is no byte code actually doing the machine learning through python, python is just the intermediator in that situation.

2

u/toejam316 4d ago

I wasn't talking about Python interacting with other libraries, I was talking about the execution of the code itself. It's literally impossible to run code on a system that doesn't at some point convert into the appropriate machine code for the platform it's executing on.

1

u/m0nk37 4d ago

K but less interaction for a better result matters. 

1

u/toejam316 4d ago

We're not discussing the best solution here.

7

u/nimrag_is_coming 5d ago

Python doesn't JIT compile, and it can't really very easily due to how dynamic it is, ie every time a piece of code runs it might actually run something different depending on what type a variable is etc.

You probably technically could turn it into assembly but then it's basically going to be a virtual machine with abstract types rather than being like actual raw assembly, so you've gained almost nothing compared to just running bytecode in an interpreter.

15

u/i_only_eat_purple 5d ago

CPython (the reference implementation that most people use) has an experimental JIT compiler since 3.13. https://peps.python.org/pep-0744/

7

u/rosuav 5d ago

PyPy JIT-compiles, and CPython currently has a JIT compiler too, although that might be removed.

13

u/Ok-Scheme-913 5d ago

Tell that to the multiple implementations of Pythons that are jit compiled, like GraalPython.

A programming language is just that, a language. Sure, some are easier to compile to efficient machine code than others, but there is no law forbidding a sufficiently smart compiler to work 3 days and prove that this ultra efficient simd machine code is the same program denoted by python's semantic laws, and thus that will be the compiler output.