i have code like:
max32 = 0xffffffffl print(sys.getsizeof(max32)) >>32 which written in python 2.
now need make sure code compatible in python 3. there no long integer in python3. how do that?
using pep 0237 - long has been renamed int , remove l , use it. example -
>>> max64 = 0xffffffffffffffff >>> max64 18446744073709551615 also whats new in python 3.0 -
pep 0237: essentially, long renamed int. is, there 1 built-in integral type, named int; behaves old long type.
also, in python 3.x , seems int has variable size depending on integer stored in -
>>> max64 = 0xffffffffffffffff >>> sys.getsizeof(max64) 22 >>> max32 = 0xffffffff >>> sys.getsizeof(max32) 18 >>> max67 = 0xffffffffffffffffffffffffffffff >>> sys.getsizeof(max67) 28 >>> max100 = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >>> sys.getsizeof(max100) 68 so should not depend on size of bytes in code.
Comments
Post a Comment