Back

Python - Memory death with two lines

I’ve just shot my computer into a trashing death with just two lines of Python.

I’ve wrote a routine to check if a number is of the form 2^n and wanted to test it. And here you go

This will crash your computer

def isPow2(x) : return x & (~(x-1)) == x
'  '.join( [str(x) for x in range(2**32) if isPow2(x)] )

Well, stupid me. Think before you type ;-)

Licensed under CC BY-NC-SA 4.0