Serhiy Storchaka added the comment:

Tests in the article don't look reliable. For example bytes_percent() and 
bytes_plus() test nothing, because b"%s %s" % (b"hi", b"there") and b"hi" + b" 
" + b"there" are evaluated at compile time.

Yes, bytes.join(sequence) is a little slower on Python 3 for short sequences. 
But for long sequences Python 3 is faster.

The code for bytes.join() is already too complex, and the proposed optimization 
makes it more complicated. And the optimization decreases performance on my 
netbook:

$ ./python -m timeit -s "sep=b' '; seq=(b'hello', b'world')" -- 'sep.join(seq); 
sep.join(seq); sep.join(seq); sep.join(seq); sep.join(seq); sep.join(seq); 
sep.join(seq); sep.join(seq); sep.join(seq); sep.join(seq)'

Python 2.7: 100000 loops, best of 3: 7.24 usec per loop
Python 3.6 unpatched: 100000 loops, best of 3: 8.62 usec per loop
Python 3.6 patched: 100000 loops, best of 3: 9.11 usec per loop

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28004>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to