我正在研究python中的位操作。我注意到,每次我移动整数的位表示时,它都会继续工作。这在python中是如何工作的并且安全吗?这会在某些时候导致内存溢出吗?这是我跑的示例测试,看看我是否可以坚持下去。 https://repl.it/KPp2/0
value = (1 << 20)
print "20 bits", value, value.bit_length()
value <<= 12
print "32 bits", value, value.bit_length()
value <<= 12
print "44 bits", value, value.bit_length()
value <<= 20
print "64 bits", value, value.bit_length()
value <<= 8
print "72 bits", value, value.bit_length()
value <<= 56
print "128 bits", value, value.bit_length()
value <<= 128
print "256 bits", value, value.bit_length()
value <<= 256
print "512 bits", value, value.bit_length()
value <<= 512
print "1024 bits", value, value.bit_length()