[issue3459] optimize bytes.join()

2008-08-02 Thread Terry J. Reedy
Terry J. Reedy <[EMAIL PROTECTED]> added the comment: >bl = [b'a']*2 gives a 2% slowdown: >bl = [b'', b'a'] gives a 20% speedup: If the second case is less than 9% of cases, which I expect is true, the change would cause an average slowdown ;-) >I encountered this when trying to optimize io.Buf

[issue3459] optimize bytes.join()

2008-08-02 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Well as I said it occurred to me when doing some measurements of BufferedReader performance, but I agree that the gain may not justify the complexity. If nobody objects, feel free to close the issue. ___ Py

[issue3459] optimize bytes.join()

2008-08-02 Thread Martin v. Löwis
Martin v. Löwis <[EMAIL PROTECTED]> added the comment: I dislike this change, not because of the potential slowdown, but because of the added code complexity. How plausible is it that you want to join a list of bytes objects, and the list has more than one item, yet all but one item are empty? I

[issue3459] optimize bytes.join()

2008-08-01 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: bl = [b'', b'a'] gives a 20% speedup: before patch: 100 loops, best of 3: 0.443 usec per loop after patch: 100 loops, best of 3: 0.349 usec per loop (20% speedup) bl = [b'a']*2 gives a 2% slowdown: before patch: 100 loops, best

[issue3459] optimize bytes.join()

2008-08-01 Thread Terry J. Reedy
Terry J. Reedy <[EMAIL PROTECTED]> added the comment: How much does the optimization speed up (or slow down?) a more normal case when it is applicable? bl = [b'', b'a'] How much does the optimization slow down the normal case where it is not applied? bl = [b'a']*2 bl = [b'a']*1 Could

[issue3459] optimize bytes.join()

2008-07-29 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: Raymond, Martin, any opinion on this? -- nosy: +loewis, rhettinger ___ Python tracker <[EMAIL PROTECTED]> ___

[issue3459] optimize bytes.join()

2008-07-28 Thread Antoine Pitrou
New submission from Antoine Pitrou <[EMAIL PROTECTED]>: When the separator is empty and the sequence only contains one non-empty item, it is possible to optimize b"".join([...]) by simply returning the non-empty item. Since b"".join() is the recommended idiom to join large strings together, I th