views:

115

answers:

2

I get an response in Python program from SQL server. How big can this response be? What is the maximum? Coult it be as much as about 100 mb?

+4  A: 

There's no reason you can't hold 100 MB of data in Python, system memory permitting. But you should try to use an iterator, rather than reading the whole result set into a list.

Matthew Flaschen
+4  A: 

See sys.maxsize: http://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
2147483647
>>> 

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.

Nicholas Knight