Youre known for being a wrapper for the C/C++ applications real developers used to make Machine Learning, you goddamn hack (Ive recently had to start maintaining a python microservice and I'm getting real heated about how shit python is)
That isn't quite the same. C/C++ compile into assembly, which means the code is fully converted. Python is typically simulated by an interpreter, so the code itself doesn't compile into any lower-level language. When they say it "wraps C/C++ code", they really mean that instead of simulating the python byte code, the interpreter runs a library that wasn't written in python at all.
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.
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.
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.
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.
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.
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.
Yea at runtime when it's interpreted, and it still has to do a lot of checks and extra stuff whenever it runs a line of code because it's still not machine code
That means it e.g. takes longer for a big pure Python program to start. Because it has to first compile the Python code into Bytecode. With a Language like C/C++/Rust. this happens at compile time and straight to native machine code.
So the interpreter has to run through this whole block of C, stepping down into functions like PyNumber_Add(). This whole block of C code is compiled into the interpreter. But it can not be optimized much during compile time, because all of these e.g. if() need to be evaluated at rutime.
While in e.g. C, if the types of the objects you want to add together (e.g. 2x int) are known at compile time, it will be just a single line of C code that will compile into much fewer machine instructions and thus run faster.
No, that's not how it works. It's a wrapper because all complicated stuff is implemented in a real language and you wrap it with Python. No one does this with assembly.
Well, do you (live!) rewire your house to turn on the lamp in the kitchen, or add a switch that you can press and have it turned on/off instantly?
Sure, it may be "more efficient" to have a single real wire go to the lamp directly instead of the inefficiency of a switch. Oh and I don't like touching live wires either (heh, this analogue works quite well)
View all comments
Show parent comment
129
u/theotherdoomguy 3d ago
Youre known for being a wrapper for the C/C++ applications real developers used to make Machine Learning, you goddamn hack (Ive recently had to start maintaining a python microservice and I'm getting real heated about how shit python is)