The Register has a story about a Python compiler called Codon that turns Python code into native machine code without a runtime performance hit.:
Python is among the one of the most popular programming languages, yet it's generally not the first choice when speed is required.
"Typical speedups over Python are on the order of 10-100x or more, on a single thread," the Codon repo declares. "Codon's performance is typically on par with (and sometimes better than) that of C/C++."
"Unlike other performance-oriented Python implementations (such as PyPy or Numba), Codon is built from the ground up as a standalone system that compiles ahead-of-time to a static executable and is not tied to an existing Python runtime (e.g., CPython or RPython) for execution," the paper says. "As a result, Codon can achieve better performance and overcome runtime-specific issues such as the global interpreter lock."
C++ Weekly - Ep 366 - C++ vs Compiled Python (Codon) performs a benchmark by running the same algorithm in Python (Codon) 8.4 seconds and C++ which takes 0.09 seconds. The video also points out the following:
We need a python code that works with codon. It takes some porting. We have to give types. It is a lot like C++ in this regard.
(Score: 4, Funny) by Barenflimski on Tuesday March 14, @03:19AM (3 children)
I hope the software on my car is running C++, cuz I like to go fast!
But in all seriousness, my robot I made which is coded in Python to push the stick that trips the dominoes that knocks a tennis ball that falls in a bucket to pull a lever that flips on my lights, doesn't need to execute 10x - 100x faster. It also has more libraries for actuators that are easy to work with.
I'd even argue that without physical access, you aren't going to buffer overflow my robot.
I do love memcpy() though....
(Score: 4, Interesting) by JoeMerchant on Tuesday March 14, @01:46PM (1 child)
It's no surprise to me at all.
As long as the code you are writing isn't doing anything much, Python is fine.
If there's ever anything resembling "heavy lifting" in a Python project, you're gonna need to put that in a module - usually C or C++, Fortran works too, or... you're gonna have a veeeeery sloooooooow program.
I use Python for my Pi Pico projects, because the dev environment is much easier to work with than the Pico SDK for C, plus: my Pico projects aren't doing much in the way of actual computation.
Otherwise, I really despise systems of programs written in collections of languages with assemblages of compilers, interpreters, and other toolchain when you could do the job with a single language and a single toolchain. Makefiles should be dead simple, when the makefile is more complex than your code, you're doing it wrong.
Україна досі не є частиною Росії Слава Україні🌻 https://news.stanford.edu/2023/02/17/will-russia-ukraine-war-end
(Score: 0) by Anonymous Coward on Wednesday March 15, @09:12AM
From what I see most stuff isn't heavy lifting. If you're trying to do a FPS shooter or 1Gbps/10Gbps servers that are pushing the limits of hardware then sure use stuff like C or C++.
Nowadays with GHz CPUs perl can do 10 million string concats in less than 0.8 seconds in a VM. That's fast enough for many use cases.
For work, I wrote a DHCP server in Perl more than a decade ago, no buffer overflow[1] vulnerabilities in my code. Was more than fast enough back then, should be even faster on current hardware. In fact it was even faster than the ISC DHCP server for some of the things we needed the DHCP server to do.
[1] It's in Perl so by definition if there are any buffer overflows it would be a bug in other people's code (e.g. the perl developers) not mine.
(Score: 3, Interesting) by istartedi on Tuesday March 14, @07:09PM
The right tool for the job. I took a robotics lab course when I was in school. We had to do a simple pick and place task, and there was actually a circuit to build that would switch something on and start it. We had all been taught about switching transistors, so that was the first thought but getting the circuit design correct actually turned out to be a hassle. Those of us who had dabbled in electronics outside of school (about half the class) decided to use a relay. I'm given to understand that few relays can switch must faster than 1 kHz--orders of magnitude slower than the transistor. The circuit was dirt simple though, worked the first time, and reliable enough for a lab where we just had to have it working for one day to pass. That dirt slow mechanical relay was the right tool for the job.
Appended to the end of comments you post. Max: 120 chars.