[Python-Dev] Inplace operations for PyLong objects (original) (raw)

Joe Jevnik jjevnik at quantopian.com
Fri Sep 1 21:16:37 EDT 2017


The string concat optimization happens in the interpreter dispatch for INPLACE_ADD

On Fri, Sep 1, 2017 at 9:10 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

Chris Angelico wrote:

This particular example is safe, because the arguments get passed individually - so 'args' has one reference, plus there's one more for the actual function call

However, that's also true when you use the += operator, so if the optimisation is to trigger at all in any useful case, the refcount threshold needs to be set higher than 1. Some experiments I did suggest that if you set it high enough for x += y to trigger it, then it will also be triggered in Joe's case. BTW, isn't there already a similar optimisation somewhere for concatenating strings? Does it still exist? How does it avoid this issue? -- Greg


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/joe% 40quantopian.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170901/d9f1b314/attachment.html>



More information about the Python-Dev mailing list