What is the maximum size of variable in python?

See sys.maxsize: //docs.python.org/library/sys.html

The largest positive integer supported by the platform’s Py_ssize_t type, and thus the maximum size lists, strings, dicts, and many other containers can have.

On my MacBook Pro with a 64-bit build of CPython, it's quite sensibly 263-1 bytes:

>>> import sys
>>> sys.maxsize
9223372036854775807
>>> 

While on my 32-bit Linux box, it's 2^31-1:

>>> import sys
>>> sys.maxsize

>>> 

In practice, of course, you're unlikely to be able to actually make use of objects this large, but you can expect to run into serious practical problems [like, say, being out of memory or taking forever to load/save objects from storage] before you hit the theoretical limits.

Python allow you to only take care about variable name and ignore it's
size because pyhton dynamicly allocate it
so what's the limit in the allocated size in the memory

Dec 31 '07 #1

En Mon, 31 Dec 2007 15:40:31 -0200, هنداوى

Chủ Đề