[Python-Dev] speeding up PyObject_GetItem
Hrvoje Niksic
hrvoje.niksic at avl.com
Tue Mar 24 10:30:46 CET 2009
Nick Coghlan wrote:
>> Many of the routines in abstract.c check their parameters for NULL, as a
>> sanity check, and throw a SystemError if NULL is detected. I'm tempted
>> to suggest making these checks only when Py_DEBUG is defined, but I
>> suspect if you wanted it that way, you would have changed it already. ;)
>>
>> Assuming you really want the NULL checks in production Python, there are
>> 5 checks for NULL even though there are only two parameters. Seems like
>> overkill?
>
> The main problem is that many of these methods are not only used
> internally, but are *also* part of the public C API made available to
> extension modules. We want misuse of the latter to trigger exceptions,
> not segfault the interpreter.
Agreed, and more importantly, I have yet to be convinced that those NULL
checks introduce a measurable slowdown. Daniel, have you tried
measuring the performance difference with only the NULL checks removed?
More information about the Python-Dev
mailing list