3 ms·
On small trick that Pythonistas hate: x = x if None else x Saves a ton of CPU time and is beautiful.
by tosser 8y ago
On small trick that Pythonistas hate:
x = x if None else x
Saves a ton of CPU time and is beautiful.
- kjeetgill 8y agoHuh, what's that do? It seems to assign x = x which is reminiscent of my pet "ugly" optimization: adding x = x to the top of a nested scope. It binds the x from a global scope to x in a local one. Local variable lookup can be substantialy faster given a hot enough loop.
- chatnati 8y agothis is all kinds of stupid