[Python-checkins] CVS: python/dist/src/Lib/test test_gc.py,1.10,1.11
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 05 Oct 2001 13:51:40 -0700
- Previous message: [Python-checkins] CVS: distutils/distutils __init__.py,1.21,1.22
- Next message: [Python-checkins] CVS: python/dist/src/Objects complexobject.c,2.49,2.50 dictobject.c,2.113,2.114 fileobject.c,2.131,2.132 floatobject.c,2.100,2.101 funcobject.c,2.45,2.46 listobject.c,2.101,2.102 longobject.c,1.110,1.111 moduleobject.c,2.38,2.39 stringobject.c,2.136,2.137 tupleobject.c,2.60,2.61 typeobject.c,2.89,2.90 unicodeobject.c,2.117,2.118
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30886/Lib/test
Modified Files:
test_gc.py
Log Message:
Enable GC for new-style instances. This touches lots of files, since
many types were subclassable but had a xxx_dealloc function that
called PyObject_DEL(self) directly instead of deferring to
self->ob_type->tp_free(self). It is permissible to set tp_free in the
type object directly to _PyObject_Del, for non-GC types, or to
_PyObject_GC_Del, for GC types. Still, PyObject_DEL was a tad faster,
so I'm fearing that our pystone rating is going down again. I'm not
sure if doing something like
void xxx_dealloc(PyObject *self)
{
if (PyXxxCheckExact(self))
PyObject_DEL(self);
else
self->ob_type->tp_free(self);
}
is any faster than always calling the else branch, so I haven't
attempted that -- however those types whose own dealloc is fancier
(int, float, unicode) do use this pattern.
Index: test_gc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** test_gc.py 2001/10/02 21:24:57 1.10
--- test_gc.py 2001/10/05 20:51:38 1.11
***************
*** 74,77 ****
--- 74,95 ----
expect_nonzero(gc.collect(), "instance")
+ def test_newinstance():
+ class A(object):
+ pass
+ a = A()
+ a.a = a
+ gc.collect()
+ del a
+ expect_nonzero(gc.collect(), "newinstance")
+ class B(list):
+ pass
+ class C(B, A):
+ pass
+ a = C()
+ a.a = a
+ gc.collect()
+ del a
+ expect_nonzero(gc.collect(), "newinstance(2)")
+
def test_method():
# Tricky: self.__init__ is a bound method, it references the instance.
***************
*** 171,174 ****
--- 189,193 ----
run_test("dynamic classes", test_dynamicclass)
run_test("instances", test_instance)
+ run_test("new instances", test_newinstance)
run_test("methods", test_method)
run_test("functions", test_function)
- Previous message: [Python-checkins] CVS: distutils/distutils __init__.py,1.21,1.22
- Next message: [Python-checkins] CVS: python/dist/src/Objects complexobject.c,2.49,2.50 dictobject.c,2.113,2.114 fileobject.c,2.131,2.132 floatobject.c,2.100,2.101 funcobject.c,2.45,2.46 listobject.c,2.101,2.102 longobject.c,1.110,1.111 moduleobject.c,2.38,2.39 stringobject.c,2.136,2.137 tupleobject.c,2.60,2.61 typeobject.c,2.89,2.90 unicodeobject.c,2.117,2.118
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]