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)