This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients arigo, brandtbucher, pablogsal, rhettinger, serhiy.storchaka, tim.peters
Date 2019-03-13.16:57:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552496262.14.0.420788786889.issue36229@roundup.psfhosted.org>
In-reply-to
Content
I apologize - I should have been clearer about what this accomplishes. I'll use list addition as an example, but this works for any binary operation on these containers.

If the left operand has a refcount of exactly one, it will simply mutate in-place rather than making an unnecessary copy. The simplest example of this is with literals:

[0] + list1

This just modifies the literal [0] in-place rather than creating an unnecessary copy. However, the more common use case is adding named lists. Currently, when adding list1 + list2 + list3, two copies (with one reference each) are made:

- The intermediate result of list1 + list2.
- The sum of this intermediate result and list3.

Only the second of these is actually returned - the first is used once and thrown away. The effect of this patch is to only create *at most one* (instead of n-1) copy for any arbitrarily long list summation, as this intermediate result will just mutate in-place for lists 3-n.
History
Date User Action Args
2019-03-13 16:57:42brandtbuchersetrecipients: + brandtbucher, tim.peters, arigo, rhettinger, serhiy.storchaka, pablogsal
2019-03-13 16:57:42brandtbuchersetmessageid: <1552496262.14.0.420788786889.issue36229@roundup.psfhosted.org>
2019-03-13 16:57:42brandtbucherlinkissue36229 messages
2019-03-13 16:57:42brandtbuchercreate