07:31Should you use "not not x" instead of "bool(x)" in Python? (NO!)
From the creator
not not x is faster than bool(x), but should you use it? not not x is faster than bool(x) in Python, even though they compute the same thing. But why? And does this mean you should start using not not x? In this video I'll explain why not not x is faster than bool(x), and also why you still shouldn't use it. Note: technically bool is not a function, it is a class, and by calling the bool "function" I mean calling the constructor of the class. Erratum: At 2:30 bool() gives False, not True. This doesn't affect the speed considerations in the video. ― mCoding with James Murphy (https://mcoding.io) Source code: https://github.com/mCodingLLC/VideosSampleCode How an x becomes a bool: https://www.youtube.com/watch?v=fpN2ieYxXO0 SUPPORT ME ⭐ --------------------------------------------------- Patreon: https://patreon.com/mCoding Paypal: https://www.paypal.com/donate/?hosted_button_id=VJY5SLZ8BJHEE Other donations: https://mcoding.io/donate Top patrons and donors: Laura M, Jameson, John Martin, Vahnekie, Pieter G, Sigmanificient BE ACTIVE IN MY COMMUNITY 😄 --------------------------------------------------- Discord: https://discord.gg/Ye9yJtZQuN Github: https://github.com/mCodingLLC/ Reddit: https://www.reddit.com/r/mCoding/ Facebook: https://www.facebook.com/james.mcoding CHAPTERS --------------------------------------------------- 0:00 Intro 0:48 First test not not vs bool 1:24 Name lookup 3:19 Bytecode comparison 4:53 Second test vs dunder bool and nop 5:29 Third test vs i
Published 2021-08-21 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.





