[issue6616] PyList_APPEND (append without incref)

2009-08-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I know the API well enough (with manipulating dicts/lists etc) > and I still want this function for the sake of convenience. Given that your level of skill is higher than the average user, I recommend adding this to your own standard libraries or headers.

[issue6616] PyList_APPEND (append without incref)

2009-08-01 Thread Campbell Barton
Campbell Barton added the comment: Hi Raymond, in general I agree with your comments that adding 2 ways to do things is not great. The reason I still think this is an advantage is that I know the API well enough (with manipulating dicts/lists etc) and I still want this function for the sake of c

[issue6616] PyList_APPEND (append without incref)

2009-08-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: > This simple patch allows... > PyList_APPEND(list, PyFloat_FromDouble(x)) This isn't a good idea because the error checking for the inner function is lost. The current API encourages keeping one function per line so that the ref counting and error-check

[issue6616] PyList_APPEND (append without incref)

2009-08-01 Thread Campbell Barton
New submission from Campbell Barton : This patch was made on python r74276 Often when writing in C/Python I want to append to a list within a C loop of an unknown length. When this is done for newly created PyObject (which is quite common) - you need to assign each item to a variable and then de