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 serhiy.storchaka
Recipients benjamin.peterson, ezio.melotti, jcon, pitrou, serhiy.storchaka, terry.reedy, vstinner
Date 2012-04-08.17:59:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1333908098.13774.49.camel@raxxla>
In-reply-to <1333898045.47.0.726917765654.issue12805@psf.upfronthosting.co.za>
Content
> Honestly, I don't think there's much point in these optimizations. The first one ("The sequence length and separator length are both 0") is probably useless.

This optimization changes the behavior.

...     def __repr__(self): return 'B(' + super().__repr__() + ')'
... 
>>> B()
B(b'')
>>> B().join([])
b''

With the patch we get B(b'').

Regardless of whether optimization (which is negligible in this case), I don't know whether to consider such side effect desirable or undesirable.

bytes.join need to optimize for the 0- and 1-byte delimiter, but the proposed patch leads to pessimization:

Unpatched:
$ ./python -m timeit -s 'seq=[bytes([i]*100000) for i in range(256)]' 'b"".join(seq)'
10 loops, best of 3: 43.3 msec per loop

Patched:
$ ./python -m timeit -s 'seq=[bytes([i]*100000) for i in range(256)]' 'b" ".join(seq)'
10 loops, best of 3: 70.3 msec per loop
History
Date User Action Args
2012-04-08 17:59:16serhiy.storchakasetrecipients: + serhiy.storchaka, terry.reedy, pitrou, vstinner, benjamin.peterson, ezio.melotti, jcon
2012-04-08 17:59:16serhiy.storchakalinkissue12805 messages
2012-04-08 17:59:15serhiy.storchakacreate