[issue37512] Error in the documentation about string concatenation

2019-07-08 Thread Brett Cannon
Brett Cannon added the comment: I'm going to close this as we try to avoid documenting CPython-specific details unless absolutely necessary. And in the case of documenting the str type we should avoid that. So thanks for the suggestion, Dmitriy, but we will just leave this as a pleasant sur

[issue37512] Error in the documentation about string concatenation

2019-07-06 Thread Dmitriy
Dmitriy added the comment: Yes, optimization is really not working in case of prepending. In case of multiple references I couldn't get quadratic time grow. Concerning the Windows, yes, the optimization may be not always efficient: >>> timeit('a+="a"', setup='a=""', number=1) 0.001169099

[issue37512] Error in the documentation about string concatenation

2019-07-05 Thread Steven D'Aprano
Steven D'Aprano added the comment: Eric is correct that this is a CPython optimization, it is not a language feature. Furthermore, it is an optimization that can be affected by rather subtle factors such as the operating system memory management. Here is a thread demonstrating that code tha

[issue37512] Error in the documentation about string concatenation

2019-07-05 Thread Eric V. Smith
Eric V. Smith added the comment: It's my understanding that this is a quality of implementation issue, and that in other (non-CPython) implementations, the run time for repeated concatenation may indeed be quadratic. The optimization in CPython relies on knowing the reference count is 1. If

[issue37512] Error in the documentation about string concatenation

2019-07-05 Thread Dmitriy
New submission from Dmitriy : There is an error in documentation about string concatenation: https://docs.python.org/3/library/stdtypes.html --- Common Sequence Operations [...] 6. Concatenating immutable sequences always results in a new object. This means that building up a sequence by repe