[Python-Dev] are NULL checks in Objects/abstract.c really needed?

Michal Vitecek fuf@mageo.cz
Thu, 13 Mar 2003 14:36:09 +0100


[this was sent to python-list, but i'm re-posting here as told by Skip]

 hello,

 i had a quick look at Objects/abstract.c in 2.2.2's source. almost
 every function there checks whether the objects it's passed are not
 NULL. if they are, SystemError exception occurs. since i've never come
 across such exception i've commented out those checks.

 the resulting python binary did 6.5% more pystones on average (the
 numbers are below). my question is: are those checks really necessary
 in non-debug python build?

 the pystone results:

 BEFORE:

$ for (( i = 0; i <= 5; i++ )); do ./pystone.py; done
Pystone(1.1) time for 10000 passes = 0.6
This machine benchmarks at 16666.7 pystones/second
Pystone(1.1) time for 10000 passes = 0.56
This machine benchmarks at 17857.1 pystones/second
Pystone(1.1) time for 10000 passes = 0.58
This machine benchmarks at 17241.4 pystones/second
Pystone(1.1) time for 10000 passes = 0.57
This machine benchmarks at 17543.9 pystones/second
Pystone(1.1) time for 10000 passes = 0.57
This machine benchmarks at 17543.9 pystones/second

 AFTER:

$ for (( i = 0; i <= 5; i++ )); do ./pystone.py; done
Pystone(1.1) time for 10000 passes = 0.54
This machine benchmarks at 18518.5 pystones/second
Pystone(1.1) time for 10000 passes = 0.57
This machine benchmarks at 17543.9 pystones/second
Pystone(1.1) time for 10000 passes = 0.55
This machine benchmarks at 18181.8 pystones/second
Pystone(1.1) time for 10000 passes = 0.52
This machine benchmarks at 19230.8 pystones/second
Pystone(1.1) time for 10000 passes = 0.52
This machine benchmarks at 19230.8 pystones/second
Pystone(1.1) time for 10000 passes = 0.54

-- 
		fuf		(fuf@mageo.cz)