What is the max length of a python string?

后端 未结 2 1675
既然无缘
既然无缘 2020-11-27 04:47

If it is environment-independent, what is the theoretical maximum number of characters in a python string?

Also if it differs with version number I\'d like to know i

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 05:10

    With a 64-bit Python installation, and (say) 64 GB of memory, a Python 2 string of around 63 GB should be quite feasible (if not maximally fast). If you can upgrade your memory much beyond that (which will cost you an arm and a leg, of course), your maximum feasible strings should get proportionally longer. (I don't recommend relying on virtual memory to extend that by much, or your runtimes will get simply ridiculous;-).

    With a typical 32-bit Python installation, of course, the total memory you can use in your application is limited to something like 2 or 3 GB (depending on OS and configuration), so the longest strings you can use will be much smaller than in 64-bit installations with ridiculously high amounts of RAM.

提交回复
热议问题