相关疑难解决方法(0)

如何在Python中确定对象的大小?

在C中,我们可以找到的大小int,char等我想知道如何获得物体的大小就像一个字符串,整数,等在Python.

相关问题:Python列表(元组)中每个元素有多少字节?

我使用的XML文件包含指定值大小的大小字段.我必须解析这个XML并进行编码.当我想更改特定字段的值时,我将检查该值的大小字段.在这里,我想比较一下我输入的新值是否与XML中的值相同.我需要检查新值的大小.在字符串的情况下,我可以说它的长度.但是在int,float等的情况下我很困惑.

python memory memory-management object sizeof

606
推荐指数
12
解决办法
53万
查看次数

类的实例使用什么资源?

How efficient is python (cpython I guess) when allocating resources for a newly created instance of a class? I have a situation where I will need to instantiate a node class millions of times to make a tree structure. Each of the node objects should be lightweight, just containing a few numbers and references to parent and child nodes.

For example, will python need to allocate memory for all the "double underscore" properties of each instantiated object (e.g. the docstrings, …

python memory-management cpython class instance

14
推荐指数
4
解决办法
500
查看次数

标签 统计

memory-management ×2

python ×2

class ×1

cpython ×1

instance ×1

memory ×1

object ×1

sizeof ×1