Miguel Grinberg’s response when someone asks how to deal with Python being such a slow language is that Python is by far the fastest to write, cleanest, more maintainable programming language known, and that a bit of a runtime performance penalty is a small price to pay when rewarded with significant productivity gains.
I rarely feel Python slows me down, and on the other side I constantly marvel at how fast I code with it compared to other languages.
I decided to pass the time running some benchmarks to help me form a better mental image of Python’s often criticized performance.
Based on my analysis I’m pleasantly surprised with the performance improvements Python has received in the last couple of years starting with Python 3.11, and I’m also frankly blown away by PyPy, which I expected to be only marginally faster than CPython and is instead running at or close to Node.js speeds. I’m definitely going to play more with PyPy going forward!
Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.
Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!
Python for Microcontrollers – Adafruit Daily — Select Python on Microcontrollers Newsletter: PyCon AU 2024 Talks, New Raspberry Pi Gear Available and More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi
EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey
This article is telling me that, best case scenario, in this synthetic benchmark, Python uses over 6 times the CPU time as Rust. Problem is, people making the claim that Python is slow are not comparing it to rust, we are comparing it to C, where if I had to make a wild guess, the difference is probably even more dramatic.
This tells me the same thing I’ve already been observing — Python is awesome for developers (especially students), but C & Rust are awesome for real human users, and our natural ecosystem. If developers could spend a little more time ensuring their software consumes 1/6th as much energy, it should be illegal not to. Inefficient high level languages are no doubt responsible for a drop in life expectancy due to energy consumption. It makes me genuinely sick how some communities are so ready to hand wave away this factor.
As my algorithms professor likes to remind us all the time, python library functions are not “free” but have time and space costs of their own, sometimes n^2 or worse. I wonder if part of people’s issues with python includes the proclivity people seem to have for monstrosities like this:
for i in list:
dosomething(list.index(i))
Which is something my professor mentioned having seen in the wild before.
This article is telling me that, best case scenario, in this synthetic benchmark, Python uses over 6 times the CPU time as Rust. Problem is, people making the claim that Python is slow are not comparing it to rust, we are comparing it to C, where if I had to make a wild guess, the difference is probably even more dramatic.
This tells me the same thing I’ve already been observing — Python is awesome for developers (especially students), but C & Rust are awesome for real human users, and our natural ecosystem. If developers could spend a little more time ensuring their software consumes 1/6th as much energy, it should be illegal not to. Inefficient high level languages are no doubt responsible for a drop in life expectancy due to energy consumption. It makes me genuinely sick how some communities are so ready to hand wave away this factor.
As my algorithms professor likes to remind us all the time, python library functions are not “free” but have time and space costs of their own, sometimes n^2 or worse. I wonder if part of people’s issues with python includes the proclivity people seem to have for monstrosities like this:
for i in list:
dosomething(list.index(i))
Which is something my professor mentioned having seen in the wild before.