Message 337882 - Python tracker

Message337882

Author arigo
Recipients arigo, brandtbucher, pablogsal, rhettinger, serhiy.storchaka, tim.peters
Date 2019-03-13.22:57:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552517874.88.0.394484895272.issue36229@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-03-13 22:57:54arigosetrecipients: + arigo, tim.peters, rhettinger, serhiy.storchaka, pablogsal, brandtbucher
2019-03-13 22:57:54arigosetmessageid: <1552517874.88.0.394484895272.issue36229@roundup.psfhosted.org>
2019-03-13 22:57:54arigolinkissue36229 messages
2019-03-13 22:57:54arigocreate