Armin Rigo <[email protected]> added the comment:
This patch is based on the following reasoning: if 'a' is a list and the
reference count of 'a' is equal to 1, then we can mutate in-place 'a' in a call
to 'a->ob_type->tp_as_sequence->list_concat'. Typically that is called from
'PyNumber_Add(a, b)'. The patch is only correct for the case where
PyNumber_Add() is called from Python/ceval.c. It is clearly wrong if you
consider calls to PyNumber_Add() from random C extension modules. Some
extension modules' authors would be very surprised if the following code starts
giving nonsense:
PyObject *a = PyList_New();
PyObject *b = PyNumber_Add(a, some_other_list);
/* here, OF COURSE a must still be an empty list and b != a */
By comparison, if you consider the hack that I'm guilty for doing long ago to
improve string concatenation, you'll see that it is done entirely inside
ceval.c, and not in stringobject.c or unicodeobject.c.
For this reason I consider the whole patch, as written now, as bogus.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36229>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com