Python列表可以有多大? [英] How Big can a Python List Get?

查看:96
本文介绍了Python列表可以有多大?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Python中,列表可以有多大?我需要大约12000个元素的列表.我仍然可以运行诸如排序之类的列表方法吗?

In Python, how big can a list get? I need a list of about 12000 elements. Will I still be able to run list methods such as sorting, etc?

推荐答案

根据

According to the source code, the maximum size of a list is PY_SSIZE_T_MAX/sizeof(PyObject*).

PY_SSIZE_T_MAX pyport.h ((size_t) -1)>>1

在常规的32位系统上,这是(4294967295/2)/4或536870912.

On a regular 32bit system, this is (4294967295 / 2) / 4 or 536870912.

因此,在32位系统上,python列表的最大大小为 536,870,912 个元素.

Therefore the maximum size of a python list on a 32 bit system is 536,870,912 elements.

只要您拥有的元素数量等于或小于此数量,所有列表函数都应正确运行.

As long as the number of elements you have is equal or below this, all list functions should operate correctly.

这篇关于Python列表可以有多大?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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