Python 字符串的最大长度是多少? [英] What is the max length of a Python string?

查看:125
本文介绍了Python 字符串的最大长度是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果它与环境无关,那么 Python 字符串中的理论最大字符数是多少?

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

推荐答案

使用 64 位 Python 安装和(比如)64 GB 内存,大约 63 GB 的 Python 2 字符串应该是相当可行的(如果不是最大快速地).如果您可以将您的内存升级到更多(当然,这将花费您一条胳膊和一条腿),您的最大可行字符串应该成比例地更长.(我不建议依靠虚拟内存来扩展它太多,否则你的运行时会变得很荒谬;-).

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;-).

对于典型的 32 位 Python 安装,当然,您可以在应用程序中使用的总内存限制为 2 或 3 GB(取决于操作系统和配置),因此您可以使用的最长字符串将是比具有高得离谱的 RAM 的 64 位安装小得多.

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.

这篇关于Python 字符串的最大长度是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆