Use bytearray += instead of bytearray.extend
This compiles to fewer bytecodes and uses built-in slots instead of method dispatch, so it should be faster. Benchmarks show a tiny improvement (using the same benchmarks as issue #1233, so not exactly designed to test this): RPS +------+------+-------+ |Size |master|+= | +------+------+-------+ |1 |5.60 | 5.63 | +------+------+-------+ | 10 |5.49 | 5.53 | +------+------+-------+ | 100 |4.99 | 5.00| +------+------+-------+ | 1000|3.53 | 3.57| +------+------+-------+
Showing
Please register or sign in to comment