在C中,我们可以找到的大小int,char等我想知道如何获得物体的大小就像一个字符串,整数,等在Python.
我使用的XML文件包含指定值大小的大小字段.我必须解析这个XML并进行编码.当我想更改特定字段的值时,我将检查该值的大小字段.在这里,我想比较一下我输入的新值是否与XML中的值相同.我需要检查新值的大小.在字符串的情况下,我可以说它的长度.但是在int,float等的情况下我很困惑.
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, …