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

Michael Hudson mwh@python.net
Thu, 13 Mar 2003 13:45:45 +0000

Michal Vitecek <fuf@mageo.cz> writes:

>  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.

There are a number of bits of stupidly defensive programming in
Python... personally, I'd like to see the back of them.

>  the resulting python binary did 6.5% more pystones on average (the
>  numbers are below).

Wow!  Can we persuade you to try CVS HEAD?

>  my question is: are those checks really necessary
>  in non-debug python build?

This is the tricky bit, of course.  I don't think so, but it's hard to
be sure.

OTOH, it could be the easiest 5% speed up ever...


  This makes it possible to pass complex object hierarchies to
  a C coder who thinks computer science has made no worthwhile
  advancements since the invention of the pointer.
                                       -- Gordon McMillan, 30 Jul 1998