[Python-checkins] r63593 - in python/branches/okkoto-sizeof: Lib/test/test_sys.py Python/sysmodule.c

robert.schuppenies python-checkins at python.org
Sat May 24 22:05:33 CEST 2008


Author: robert.schuppenies
Date: Sat May 24 22:05:32 2008
New Revision: 63593

Log:
renamed from sys.sizeof() to sys.getsizeof(). seems to be more in line
with the other functions


Modified:
   python/branches/okkoto-sizeof/Lib/test/test_sys.py
   python/branches/okkoto-sizeof/Python/sysmodule.c

Modified: python/branches/okkoto-sizeof/Lib/test/test_sys.py
==============================================================================
--- python/branches/okkoto-sizeof/Lib/test/test_sys.py	(original)
+++ python/branches/okkoto-sizeof/Lib/test/test_sys.py	Sat May 24 22:05:32 2008
@@ -407,7 +407,7 @@
 
     def check_sizeof(self, o, size, ):
         size += self.headersize
-        result = sys.sizeof(o)
+        result = sys.getsizeof(o)
         msg = 'wrong size for ' + str(type(o)) + ': '+\
               str(result) + ' != ' + str(size)
         self.assertEqual(result, size, msg)

Modified: python/branches/okkoto-sizeof/Python/sysmodule.c
==============================================================================
--- python/branches/okkoto-sizeof/Python/sysmodule.c	(original)
+++ python/branches/okkoto-sizeof/Python/sysmodule.c	Sat May 24 22:05:32 2008
@@ -640,7 +640,7 @@
 #endif /* USE_MALLOPT */
 
 static PyObject *
-sys_sizeof(PyObject *self, PyObject *args)
+sys_getsizeof(PyObject *self, PyObject *args)
 {
 	PyObject *res;
         
@@ -651,10 +651,10 @@
 	return res;
 }
 
-PyDoc_STRVAR(sizeof_doc,
-"sizeof(object) -> long\n\
+PyDoc_STRVAR(getsizeof_doc,
+"getsizeof(object) -> long\n\
 \n\
-Return the memory footprint of an object in bytes.");
+Return the size of object in bytes.");
 
 
 
@@ -869,6 +869,7 @@
 	{"getrefcount",	(PyCFunction)sys_getrefcount, METH_O, getrefcount_doc},
 	{"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS,
 	 getrecursionlimit_doc},
+ 	{"getsizeof",	sys_getsizeof,  METH_O, getsizeof_doc},
 	{"_getframe", sys_getframe, METH_VARARGS, getframe_doc},
 #ifdef MS_WINDOWS
 	{"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS,
@@ -899,7 +900,6 @@
 	{"settrace",	sys_settrace, METH_O, settrace_doc},
 	{"gettrace",	sys_gettrace, METH_NOARGS, gettrace_doc},
 	{"call_tracing", sys_call_tracing, METH_VARARGS, call_tracing_doc},
- 	{"sizeof",	sys_sizeof,  METH_O, sizeof_doc},
 	{NULL,		NULL}		/* sentinel */
 };
 
@@ -1050,6 +1050,7 @@
 getprofile() -- get the global profiling function\n\
 getrefcount() -- return the reference count for an object (plus one :-)\n\
 getrecursionlimit() -- return the max recursion depth for the interpreter\n\
+getsizeof() -- return the size of an object in bytes\n\
 gettrace() -- get the global debug tracing function\n\
 setcheckinterval() -- control how often the interpreter checks for events\n\
 setdlopenflags() -- set the flags to be used for dlopen() calls\n\


More information about the Python-checkins mailing list