[Python-checkins] python/dist/src/Lib/test test_gc.py,1.16,1.17

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Thu, 11 Jul 2002 12:07:47 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv14525/python/Lib/test

Modified Files:
	test_gc.py 
Log Message:
test_trashcan() and supporting class Ouch():  Jeremy noted that this test
takes much longer to run in the context of the test suite than when run in
isolation.  That's because it forces a large number of full collections,
which take time proportional to the total number of gc'ed objects in the
whole system.

But since the dangerous implementation trickery that caused this test to
fail in 2.0, 2.1 and 2.2 doesn't exist in 2.3 anymore (the trashcan
mechanism stopped doing evil things when the possibility for compiling
without cyclic gc was taken away), such an expensive test is no longer
justified.  This checkin leaves the test intact, but fiddles the
constants to reduce the runtime by about a factor of 5.


Index: test_gc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_gc.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_gc.py	13 Jun 2002 11:53:12 -0000	1.16
--- test_gc.py	11 Jul 2002 19:07:45 -0000	1.17
***************
*** 182,186 ****
      def __del__(self):
          Ouch.n = Ouch.n + 1
!         if Ouch.n % 7 == 0:
              gc.collect()
  
--- 182,186 ----
      def __del__(self):
          Ouch.n = Ouch.n + 1
!         if Ouch.n % 17 == 0:
              gc.collect()
  
***************
*** 193,199 ****
      # most likely die via segfault.
  
      gc.enable()
!     N = 200
!     for count in range(3):
          t = []
          for i in range(N):
--- 193,205 ----
      # most likely die via segfault.
  
+     # Note:  In 2.3 the possibility for compiling without cyclic gc was
+     # removed, and that in turn allows the trashcan mechanism to work
+     # via much simpler means (e.g., it never abuses the type pointer or
+     # refcount fields anymore).  Since it's much less likely to cause a
+     # problem now, the various constants in this expensive (we force a lot
+     # of full collections) test are cut back from the 2.2 version.
      gc.enable()
!     N = 150
!     for count in range(2):
          t = []
          for i in range(N):