PySequence_SetItem
John Machin
sjmachin at lexicon.net
Thu Aug 17 05:50:23 EDT 2006
Fredrik Lundh wrote:
> John Machin wrote:
>
> > Are you suggesting a rework of the manual instead of inserting a X in
> > the offending py_DECREF?
>
> are you suggesting slowing things down just because of a bug in the
> documentation ?
Not explicitly; not intentionally.
> you cannot return an uninitialized list object to
> Python anyway, so there's no need to add extra checks to a function
> that's *documented* to be the equivalent of a *Python-level* sequence
> assignment.
1. It's also documented as being the recommended way of filling up a
list after PyList_New.
2. So you'd rather not change the code, and just let it segfault if
someone calls it (or PyObject_SetItem) instead of PyList_SetItem?
>
> the "I spent time debugging this, so now everyone should suffer"
> approach doesn't strike me as very Pythonic.
That's the wildest leap from scant evidence to a wrong conclusion that
I've seen for quite a while :-)
Anyway, having had a look at the code:
#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
I have to say that I'm truly sorry, I wasn't aware that that little
"skip if zero" chunk of code was up there with cancer, AIDS and bombs
-- I'll pull my head in and not refer to the topic again.
More information about the Python-list
mailing list