Message157802
> 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 |
|
Date |
User |
Action |
Args |
2012-04-08 17:59:16 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, terry.reedy, pitrou, vstinner, benjamin.peterson, ezio.melotti, jcon |
2012-04-08 17:59:16 | serhiy.storchaka | link | issue12805 messages |
2012-04-08 17:59:15 | serhiy.storchaka | create | |
|