2004年08月10日 星期二 13:21
Hollo hoxide: 嗯嗯! 感觉Python 从一开始就是关注 创造力的实现 ,而不是运行效率! 所以,丰富的数据类型后面,可能就是松散的内容管理, 但是不影响Python 的快速布属和应用是也乎,毕竟现在的内存真的不值钱了!Windows 已经开始要求独占200Mb 内存了! 当然这得是有浑厚 C 基础的同志们来关注,提升Python 的内涵是也乎?? 其实,可以利用C,写一个内存探针,嵌入到Python 脚本中运行来测试各种对象运行时的内存使用情况是也乎??? /******** [2004-08-10]13:17:47 ; hoxide wrote: hoxide> gentoo.cn,您好! hoxide> 资料不错,他的讨论证实了python中很难准确计算对象占用的内存数. hoxide> 其实现在我也对python的内存管理感兴趣,昨天发现mod_python好像存在内存泄漏的问题. hoxide> ======= 2004-08-10 12:53:49 您在来信中写道:======= >>找到一个相关的讨论 >>http://www.egenix.com/mailman-archives/egenix-users/2002-November/000156.html >> >>gentoo.cn wrote: >> >>>我的意思是:是不是可以通过计算一个Object的Struct来猜测这个Object的大小? >>>比如c='a', string="abcd" >>>那么c的类型是1c, string的类型是4c >>>calcsize('c')=1 >>>calcsize('L')=4 >>>也就是说一个数值型的对象占用4Bytes内存空间,一个字符型对象占用1Bytes内存 >>>空间? >>>对于string="abcd"这个对象,类型是4c所以占用4Bytes内存空间? >>>不知道Python如何考虑对齐的(也许他最小的单位是1Bytes所以都是8bit的倍数, >>>这样就对齐了?) >>> >>>大家都来讨论讨论啊。 >>> >>> >>> >>>limodou wrote: >>> >>> >>> >>>>gentoo.cn,您好! >>>> >>>> 那个不是内存的大小吧。而是对应的struct的大小。因为在python中都是对象,而不仅仅是数据结构。不知道:你想知道内存大小有什么用? >>>> >>>>======= 2004-08-10 11:05:42 您在来信中写道:======= >>>> >>>> >>>> >>>> >>>> >>>>>import struct >>>>>struct.pack >>>>>struct.calcsize ? >>>>> >>>>>难道使用这个方法吗? >>>>>我也想知道有什么方法来计算对象的size >>>>> >>>>>*calcsize*( fmt) >>>>> >>>>> Return the size of the struct (and hence of the string) >>>>> corresponding to the given format. >>>>> >>>>>Format characters have the following meaning; the conversion between C >>>>>and Python values should be obvious given their types: >>>>> >>>>>*Format* *C Type* *Python* *Notes* >>>>>x pad byte no value >>>>>c char string of length 1 >>>>>b signed char integer >>>>>B unsigned char integer >>>>>h short integer >>>>>H unsigned short integer >>>>>i int integer >>>>>I unsigned int long >>>>>l long integer >>>>>L unsigned long long >>>>>q long long long (1) >>>>>Q unsigned long long long (1) >>>>>f float float >>>>>d double float >>>>>s char[] string >>>>>p char[] string >>>>>P void * integer >>>>> >>>>> >>>>>tocer wrote: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>>比如: >>>>>>a=[1,2,3] >>>>>>测试 a 在内存中的所占的字节数 >>>>>> >>>>>>------------------------------------------------------------------------ >>>>>> >>>>>>_______________________________________________ >>>>>>python-chinese list >>>>>>python-chinese at lists.python.cn >>>>>>http://python.cn/mailman/listinfo/python-chinese >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>_______________________________________________ >>>>>python-chinese list >>>>>python-chinese at lists.python.cn >>>>>http://python.cn/mailman/listinfo/python-chinese >>>>> >>>>> >>>>> >>>>> >>>>> >>>>= = = = = = = = = = = = = = = = = = = = >>>> >>>> >>>> 致 >>>>礼! >>>> >>>> >>>> limodou >>>> chatme at 263.net >>>> 2004-08-10 >>>> >>>> >>>> >>>>------------------------------------------------------------------------ >>>> >>>>_______________________________________________ >>>>python-chinese list >>>>python-chinese at lists.python.cn >>>>http://python.cn/mailman/listinfo/python-chinese >>>> >>>> >>>> >>>> >>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>> >>> >> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese hoxide> = = = = = = = = = = = = = = = = = = = = hoxide> 致 hoxide> 礼! hoxide> hoxide hoxide> hoxide_dirac at yahoo.com.cn hoxide> 2004-08-10 ********************************************/ -- Free as in Freedom Zoom.Quiet #=========================================# ]Time is unimportant, only life important![ #=========================================# sender is the Bat!2.12.00
Zeuux © 2025
京ICP备05028076号