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

问题描述

我有一个计划中的项目,我想拥有的一点信息是 reference 在Python中占用了多少内存. AFAIK,Python中的引用与指针相同,我猜想它的大小与32位或64位指针相同(但我可能错了).

I have a project that I am planning, and one bit of information I'll want to have is how much memory a reference takes up in Python. AFAIK, a reference in python is the same as a pointer, and I am guessing that it would be the same size as a 32bit or 64bit pointer (but I could be wrong).

任何人都可以帮我解决这个问题,这样我就不必继续猜测了吗?

Could anyone clear this up for me, so that I don't have to go on guesswork?

推荐答案

在评论中,我和SuperBiasedMan进行了讨论. Python中引用的大小与CPU的字大小相同.因此,在32位python版本上为4个字节,在64位python版本上为8个字节.

This was answered in the comments through a discussion between me and SuperBiasedMan. The size of a reference in Python is the same as the word size for the CPU. So, it's 4 bytes on a 32bit build of python, and 8 bytes on 64bit python.

这篇关于Python:参考大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 18:11