Python论坛  - 讨论区

标题:Re[3]: [python-chinese] 如何测量一个变量或者常量在内存中的大小

2004年08月10日 星期二 15:54

Zoom.Quiet zoomquiet at infopro.cn
Tue Aug 10 15:54:28 HKT 2004

Hollo limodou:

  不能说不关心哪?!
Python 在嵌入设置中也有移植的!性能的追求是一切语言不能忽略的是也乎,不过 Python 以另外的方式来完成,当然也有提高的余地,有忐者可以开始探险哪!?


/******** [2004-08-10]15:52:50 ; limodou wrote:

limodou> tocer,您好!

limodou> 	因为使用Python根本不关心这个。不要总把C/C++里的概念在Python中使用,因为它们根本就不一样。

limodou> ======= 2004-08-10 15:33:00 您在来信中写道:=======

>>没想到这么难解决
>>
>>----- Original Message ----- 
>>From: "gentoo.cn" <gentoo.cn at 126.com>
>>To: <python-chinese at lists.python.cn>
>>Sent: Tuesday, August 10, 2004 12:53 PM
>>Subject: Re: [python-chinese] 如何测量一个变量或者常量在内存中的大小
>>
>>
>>> 找到一个相关的讨论
>>> 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
>>> _______________________________________________
>>python-chinese list
>>python-chinese at lists.python.cn
>>http://python.cn/mailman/listinfo/python-chinese
>>

limodou> = = = = = = = = = = = = = = = = = = = =
			

limodou>         致
limodou> 礼!
 
				 
limodou>         limodou
limodou>         chatme at 263.net
limodou>           2004-08-10



********************************************/

-- 
Free as in Freedom

 Zoom.Quiet                           

#=========================================#
]Time is unimportant, only life important![
#=========================================#

sender is the Bat!2.12.00



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年08月10日 星期二 16:13

limodou chatme at 263.net
Tue Aug 10 16:13:36 HKT 2004

Zoom.Quiet,您好!

	也不至于要细到要知道内存大小。

======= 2004-08-10 15:54:28 您在来信中写道:=======

>Hollo limodou:
>
>  不能说不关心哪?!
>Python 在嵌入设置中也有移植的!性能的追求是一切语言不能忽略的是也乎,不过 Python 以另外的方式来完成,当然也有提高的余地,有忐者可以开始探险哪!?
>
>
>/******** [2004-08-10]15:52:50 ; limodou wrote:
>
>limodou> tocer,您好!
>
>limodou> 	因为使用Python根本不关心这个。不要总把C/C++里的概念在Python中使用,因为它们根本就不一样。
>
>limodou> ======= 2004-08-10 15:33:00 您在来信中写道:=======
>
>>>没想到这么难解决
>>>
>>>----- Original Message ----- 
>>>From: "gentoo.cn" <gentoo.cn at 126.com>
>>>To: <python-chinese at lists.python.cn>
>>>Sent: Tuesday, August 10, 2004 12:53 PM
>>>Subject: Re: [python-chinese] 如何测量一个变量或者常量在内存中的大小
>>>
>>>
>>>> 找到一个相关的讨论
>>>> 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
>>>> _______________________________________________
>>>python-chinese list
>>>python-chinese at lists.python.cn
>>>http://python.cn/mailman/listinfo/python-chinese
>>>
>
>limodou> = = = = = = = = = = = = = = = = = = = =
>			
>
>limodou>         致
>limodou> 礼!
> 
>				 
>limodou>         limodou
>limodou>         chatme at 263.net
>limodou>           2004-08-10
>
>
>
>********************************************/
>
>-- 
>Free as in Freedom
>
> Zoom.Quiet                           
>
>#=========================================#
>]Time is unimportant, only life important![
>#=========================================#
>
>sender is the Bat!2.12.00
>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        limodou
        chatme at 263.net
          2004-08-10


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年08月10日 星期二 16:16

0.706 0.706 at 163.com
Tue Aug 10 16:16:25 HKT 2004

tocer,您好!

	不是难解决,而是用python根本就不需要这些东西,所有的东西都是对象,都是引用,内存并不需要
手动分配,为什么还要关心它的大小呢.你不妨认为python中的东西都同样大小.如果你非要钻牛角尖的
话,我只能说,python不适合你,用C吧!

======= 2004-08-10 15:33:00 您在来信中写道:=======

>没想到这么难解决
>
>----- Original Message ----- 
>From: "gentoo.cn" <gentoo.cn at 126.com>
>To: <python-chinese at lists.python.cn>
>Sent: Tuesday, August 10, 2004 12:53 PM
>Subject: Re: [python-chinese] 如何测量一个变量或者常量在内存中的大小
>
>
>> 找到一个相关的讨论
>> 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
>> _______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        0.706
        0.706 at 163.com
          2004-08-10


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年08月10日 星期二 16:29

hoxide hoxide_dirac at yahoo.com.cn
Tue Aug 10 16:29:15 HKT 2004

limodou,您好!

	我只看过python 对象部分的代码,而且只是挑着看的.

static int
roundupsize(int n)
{
	unsigned int nbits = 0;
	unsigned int n2 = (unsigned int)n >> 5;

	/* Round up:
	 * If n <       256, to a multiple of        8.
	 * If n <      2048, to a multiple of       64.
	 * If n <     16384, to a multiple of      512.
	 * If n <    131072, to a multiple of     4096.
	 * If n <   1048576, to a multiple of    32768.
	 * If n <   8388608, to a multiple of   262144.
	 * If n <  67108864, to a multiple of  2097152.
	 * If n < 536870912, to a multiple of 16777216.
	 * ...
	 * If n < 2**(5+3*i), to a multiple of 2**(3*i).
	 *
	 * This over-allocates proportional to the list size, making room
	 * for additional growth.  The over-allocation is mild, but is
	 * enough to give linear-time amortized behavior over a long
	 * sequence of appends() in the presence of a poorly-performing
	 * system realloc() (which is a reality, e.g., across all flavors
	 * of Windows, with Win9x behavior being particularly bad -- and
	 * we've still got address space fragmentation problems on Win9x
	 * even with this scheme, although it requires much longer lists to
	 * provoke them than it used to).
	 */
	do {
		n2 >>= 3;
		nbits += 3;
	} while (n2);
	return ((n >> nbits) + 1) << nbits;
 }

#define NRESIZE(var, type, nitems)				\
do {								\
	size_t _new_size = roundupsize(nitems);			\
	if (_new_size <= ((~(size_t)0) / sizeof(type)))		\
		PyMem_RESIZE(var, type, _new_size);		\
	else							\
		var = NULL;					\
} while (0)

PyObject *
PyList_New(int size)
{
	PyListObject *op;
	size_t nbytes;
	if (size < 0) {
		PyErr_BadInternalCall();
		return NULL;
	}
	nbytes = size * sizeof(PyObject *);
	/* Check for overflow */
	if (nbytes / sizeof(PyObject *) != (size_t)size) {
		return PyErr_NoMemory();
	}
	op = PyObject_GC_New(PyListObject, &PyList;_Type);
	if (op == NULL) {
		return NULL;
	}
	if (size <= 0) {
		op->ob_item = NULL;
	}
	else {
		op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
		if (op->ob_item == NULL) {
			return PyErr_NoMemory();
		}
		memset(op->ob_item, 0, sizeof(*op->ob_item) * size);
	}
	op->ob_size = size;
	_PyObject_GC_TRACK(op);
	return (PyObject *) op;
}


	上面得代码很关键,list在建立对象的时候是按照对象的个数分配了一个指针数组,大小为nbytes,是size个指向PyObject的指针.
    但是在插入元素时:
static int
ins1(PyListObject *self, int where, PyObject *v)
{
	int i;
	PyObject **items;
	if (v == NULL) {
		PyErr_BadInternalCall();
		return -1;
	}
	if (self->ob_size == INT_MAX) {
		PyErr_SetString(PyExc_OverflowError,
			"cannot add more objects to list");
		return -1;
	}
	items = self->ob_item;
	NRESIZE(items, PyObject *, self->ob_size+1);
	if (items == NULL) {
		PyErr_NoMemory();
		return -1;
	}
	if (where < 0) {
		where += self->ob_size;
		if (where < 0)
			where = 0;
	}
	if (where > self->ob_size)
		where = self->ob_size;
	for (i = self->ob_size; --i >= where; )
		items[i+1] = items[i];
	Py_INCREF(v);
	items[where] = v;
	self->ob_item = items;
	self->ob_size++;
	return 0;
}

注意
	NRESIZE(items, PyObject *, self->ob_size+1);
	这是数组大小会自动扩大,扩大的规则在roundupsize中定义了.
所以我说这个问题很难搞清楚.



======= 2004-08-10 16:13:36 您在来信中写道:=======

>Zoom.Quiet,您好!
>
>	也不至于要细到要知道内存大小。
>
>======= 2004-08-10 15:54:28 您在来信中写道:=======
>
>>Hollo limodou:
>>
>>  不能说不关心哪?!
>>Python 在嵌入设置中也有移植的!性能的追求是一切语言不能忽略的是也乎,不过 Python 以另外的方式来完成,当然也有提高的余地,有忐者可以开始探险哪!?
>>
>>
>>/******** [2004-08-10]15:52:50 ; limodou wrote:
>>
>>limodou> tocer,您好!
>>
>>limodou> 	因为使用Python根本不关心这个。不要总把C/C++里的概念在Python中使用,因为它们根本就不一样。
>>
>>limodou> ======= 2004-08-10 15:33:00 您在来信中写道:=======
>>
>>>>没想到这么难解决
>>>>
>>>>----- Original Message ----- 
>>>>From: "gentoo.cn" <gentoo.cn at 126.com>
>>>>To: <python-chinese at lists.python.cn>
>>>>Sent: Tuesday, August 10, 2004 12:53 PM
>>>>Subject: Re: [python-chinese] 如何测量一个变量或者常量在内存中的大小
>>>>
>>>>
>>>>> 找到一个相关的讨论
>>>>> 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
>>>>> _______________________________________________
>>>>python-chinese list
>>>>python-chinese at lists.python.cn
>>>>http://python.cn/mailman/listinfo/python-chinese
>>>>
>>
>>limodou> = = = = = = = = = = = = = = = = = = = =
>>			
>>
>>limodou>         致
>>limodou> 礼!
>> 
>>				 
>>limodou>         limodou
>>limodou>         chatme at 263.net
>>limodou>           2004-08-10
>>
>>
>>
>>********************************************/
>>
>>-- 
>>Free as in Freedom
>>
>> Zoom.Quiet                           
>>
>>#=========================================#
>>]Time is unimportant, only life important![
>>#=========================================#
>>
>>sender is the Bat!2.12.00
>>
>>_______________________________________________
>>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
>

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        hoxide
        hoxide_dirac at yahoo.com.cn
          2004-08-10


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年08月10日 星期二 16:30

Liming_Do Liming_Do at smics.com
Tue Aug 10 16:30:56 HKT 2004

鸟人可不是随便叫的,鲁迅好象这样骂过:一群鸟男女。
鸟人也不是新发明,N年以前就有人这么骂人了

-----原始邮件-----
发件人: python-chinese-bounces at lists.python.cn
[mailto:python-chinese-bounces at lists.python.cn]代表 limodou
发送时间: 2004年8月10日 15:51
收件人: zoomq at itcase.com; zoomq at infopro.cn; python-chinese at lists.python.
cn>
主题: Re: Re[3]: [python-chinese] moinmoin如何设置访客不能编辑页面?


Zoom.Quiet,您好!

	为什么不说“够牛”呢?鸟(diao)是骂人的话吧。

======= 2004-08-10 15:39:05 您在来信中写道:=======

>Hollo 0.706:
>
>  如果我们都能将技术修炼的仙一样,别人一提都说
>“够鸟(diao)!” 这辈子也值了!
>
>
>/******** [2004-08-10]15:38:13 ; 0.706 wrote:
>
>0.706> "Zoom.Quiet" >
>0.706> 	鸟人太难听了,改人鸟算了 
>
>0.706> ======= 2004-08-10 14:57:11 您在来信中写道:=======
>
>>>Hollo HD:
>>>
>>>PPS.
>>>今天得小空,将 wiki.woodpecker.org.cn 的文章结构调整了一下子,
>>>
>>>创造个新词儿,你审核一下子是也乎?
>>>
>>>++++++++++++++++++++++++
>>>ps:
>>>http://wiki.woodpecker.org.cn/moin.cgi/HelpOnAccessControlLists
>>>是标准的权限控制,不过麻烦些,除非根 Unix
>>>用户结合,否则没有什么意思,不过在下倒是一直没有找到如何可以让匿名用户可以写注解的,
>>>
>>>好象 Moin 不象其它的Wiki 有注解功能??
>>>
>>>++++++++++++++++++++++++++++
>>>
>>>  咦咦咦??不是说过了??
>>>按照在下的 config.py 依法处理就好的?
>>>关键的::
>>>
>>># permissions 
>>>
>>>from MoinMoin.security import Permissions 
>>>class SecurityPolicy(Permissions): 
>>>    def edit(self, pagename, **_): 
>>>        # only known users are allowed to delete 
>>>        return self.user.valid 
>>>
>>>其中 **_ 是个正则表达式,可以更进一步限定的!
>>>中蟒,就是如此干的!
>>>
>>>
>>>
>>>/******** [2004-08-10]14:47:49 ; HD wrote:
>>>
>>>HD> 呵呵,在哪里设置呀,怎么设置?zoom.q呀,说说。有人在追我了。 :)
>>>
>>>
>>>
>>>********************************************/
>>>
>>>-- 
>>>Free as in Freedom
>>>
>>> Zoom.Quiet                           
>>>
>>>#=========================================#
>>>]Time is unimportant, only life important![
>>>#=========================================#
>>>
>>>sender is the Bat!2.12.00
>>>
>>>_______________________________________________
>>>python-chinese list
>>>python-chinese at lists.python.cn
>>>http://python.cn/mailman/listinfo/python-chinese
>>>
>
>0.706> = = = = = = = = = = = = = = = = = = = =
>			
>
>0.706>         致
>0.706> 礼!
> 
>				 
>0.706>         0.706
>0.706>         0.706 at 163.com
>0.706>           2004-08-10
>
>
>
>********************************************/
>
>-- 
>Free as in Freedom
>
> Zoom.Quiet                           
>
>#=========================================#
>]Time is unimportant, only life important![
>#=========================================#
>
>sender is the Bat!2.12.00
>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        limodou
        chatme at 263.net
          2004-08-10



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年08月10日 星期二 16:51

Zoom.Quiet zoomquiet at infopro.cn
Tue Aug 10 16:51:57 HKT 2004

Hollo Liming_Do:

  嗯嗯!悠远强大的民俗文化哪!
想一想中文就那千把常用字,怎么组合这多年都穷尽了!而且各有深义!

不找骂了!

改成“行者”吧!
开源之路中国漫漫兮其修远!
吾等自将上下而求索!


/******** [2004-08-10]16:49:06 ; Liming_Do wrote:

Liming_Do> 鸟人可不是随便叫的,鲁迅好象这样骂过:一群鸟男女。
Liming_Do> 鸟人也不是新发明,N年以前就有人这么骂人了

Liming_Do> -----原始邮件-----
Liming_Do> 发件人: python-chinese-bounces at lists.python.cn
Liming_Do> [mailto:python-chinese-bounces at lists.python.cn]代表 limodou
Liming_Do> 发送时间: 2004年8月10日 15:51
Liming_Do> 收件人: zoomq at itcase.com; zoomq at infopro.cn;
Liming_Do> python-chinese at lists.python.
cn>>
Liming_Do> 主题: Re: Re[3]: [python-chinese]
Liming_Do> moinmoin如何设置访客不能编辑页面?


Liming_Do> Zoom.Quiet,您好!

Liming_Do> 	为什么不说“够牛”呢?鸟(diao)是骂人的话吧。

Liming_Do> ======= 2004-08-10 15:39:05 您在来信中写道:=======

>>Hollo 0.706:
>>
>>  如果我们都能将技术修炼的仙一样,别人一提都说
>>“够鸟(diao)!” 这辈子也值了!
>>
>>
>>/******** [2004-08-10]15:38:13 ; 0.706 wrote:
>>
>>0.706> "Zoom.Quiet" >>
>>0.706> 	鸟人太难听了,改人鸟算了 
>>
>>0.706> ======= 2004-08-10 14:57:11 您在来信中写道:=======
>>
>>>>Hollo HD:
>>>>
>>>>PPS.
>>>>今天得小空,将 wiki.woodpecker.org.cn 的文章结构调整了一下子,
>>>>
>>>>创造个新词儿,你审核一下子是也乎?
>>>>
>>>>++++++++++++++++++++++++
>>>>ps:
>>>>http://wiki.woodpecker.org.cn/moin.cgi/HelpOnAccessControlLists
>>>>是标准的权限控制,不过麻烦些,除非根 Unix
>>>>用户结合,否则没有什么意思,不过在下倒是一直没有找到如何可以让匿名用户可以写注解的,
>>>>
>>>>好象 Moin 不象其它的Wiki 有注解功能??
>>>>
>>>>++++++++++++++++++++++++++++
>>>>
>>>>  咦咦咦??不是说过了??
>>>>按照在下的 config.py 依法处理就好的?
>>>>关键的::
>>>>
>>>># permissions 
>>>>
>>>>from MoinMoin.security import Permissions 
>>>>class SecurityPolicy(Permissions): 
>>>>    def edit(self, pagename, **_): 
>>>>        # only known users are allowed to delete 
>>>>        return self.user.valid 
>>>>
>>>>其中 **_ 是个正则表达式,可以更进一步限定的!
>>>>中蟒,就是如此干的!
>>>>
>>>>
>>>>
>>>>/******** [2004-08-10]14:47:49 ; HD wrote:
>>>>
>>>>HD>
>>>>呵呵,在哪里设置呀,怎么设置?zoom.q呀,说说。有人在追我了。 :)
>>>>
>>>>
>>>>
>>>>********************************************/
>>>>
>>>>-- 
>>>>Free as in Freedom
>>>>
>>>> Zoom.Quiet                           
>>>>
>>>>#=========================================#
>>>>]Time is unimportant, only life important![
>>>>#=========================================#
>>>>
>>>>sender is the Bat!2.12.00
>>>>
>>>>_______________________________________________
>>>>python-chinese list
>>>>python-chinese at lists.python.cn
>>>>http://python.cn/mailman/listinfo/python-chinese
>>>>
>>
>>0.706> = = = = = = = = = = = = = = = = = = = =
>>			
>>
>>0.706>         致
>>0.706> 礼!
>> 
>>				 
>>0.706>         0.706
>>0.706>         0.706 at 163.com
>>0.706>           2004-08-10
>>
>>
>>
>>********************************************/
>>
>>-- 
>>Free as in Freedom
>>
>> Zoom.Quiet                           
>>
>>#=========================================#
>>]Time is unimportant, only life important![
>>#=========================================#
>>
>>sender is the Bat!2.12.00
>>
>>_______________________________________________
>>python-chinese list
>>python-chinese at lists.python.cn
>>http://python.cn/mailman/listinfo/python-chinese
>>

Liming_Do> = = = = = = = = = = = = = = = = = = = =
			

Liming_Do>         致
Liming_Do> 礼!
 
				 
Liming_Do>         limodou
Liming_Do>         chatme at 263.net
Liming_Do>           2004-08-10

Liming_Do> _______________________________________________
Liming_Do> python-chinese list
Liming_Do> python-chinese at lists.python.cn
Liming_Do> http://python.cn/mailman/listinfo/python-chinese


********************************************/

-- 
Free as in Freedom

 Zoom.Quiet                           

#=========================================#
]Time is unimportant, only life important![
#=========================================#

sender is the Bat!2.12.00



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号