DEV Community

Konstantin vz'One Enchant
Konstantin vz'One Enchant

Posted on

Checking overhead for walrus operator (:=) in Python

Purely for myself, I decided to check whether there is an overheat when using walrus (:=) in Python:

Timeit for warlus in Python

At least it works no slower, which is already pleasing.

If you look deeper, you can see that when using the walrus, the LOAD_FAST instruction is missing, it is, as it were, replaced by DUP_TOP, which in theory should work a little faster.

Top comments (0)

Dev Diairies image

User Feedback & The Pivot That Saved The Project

🔥 Check out Episode 3 of Dev Diairies, following a successful Hackathon project turned startup.

Watch full video 🎥

👋 Kindness is contagious

Explore this insightful piece, celebrated by the caring DEV Community. Programmers from all walks of life are invited to contribute and expand our shared wisdom.

A simple "thank you" can make someone’s day—leave your kudos in the comments below!

On DEV, spreading knowledge paves the way and fortifies our camaraderie. Found this helpful? A brief note of appreciation to the author truly matters.

Let’s Go!