Message91486
Optimize PyBytes_FromObject by adding special-cases for list and tuple
objects and by using _PyObject_LengthHint() instead of an arbitrary
value for the size of the initial buffer.
[Without the patch]
./python -m timeit -s "x = list(range(256))" "bytes(x)"
100000 loops, best of 3: 7.19 usec per loop
./python -m timeit -s "x = tuple(range(256))" "bytes(x)"
100000 loops, best of 3: 7.14 usec per loop
./python -m timeit -s "x = list(range(256))*100" "bytes(x)"
1000 loops, best of 3: 591 usec per loop
./python -m timeit -s "x = range(256)" "bytes(x)"
100000 loops, best of 3: 8.45 usec per loop
[With the patch]
./python -m timeit -s "x = list(range(256))" "bytes(x)"
100000 loops, best of 3: 4.43 usec per loop
./python -m timeit -s "x = tuple(range(256))" "bytes(x)"
100000 loops, best of 3: 4.53 usec per loop
./python -m timeit -s "x = list(range(256))*100" "bytes(x)"
1000 loops, best of 3: 335 usec per loop
./python -m timeit -s "x = range(256)" "bytes(x)"
100000 loops, best of 3: 7.56 usec per loop |
|
Date |
User |
Action |
Args |
2009-08-11 21:34:37 | alexandre.vassalotti | set | recipients:
+ alexandre.vassalotti |
2009-08-11 21:34:37 | alexandre.vassalotti | set | messageid: <1250026477.34.0.625583102893.issue6688@psf.upfronthosting.co.za> |
2009-08-11 21:34:36 | alexandre.vassalotti | link | issue6688 messages |
2009-08-11 21:34:36 | alexandre.vassalotti | create | |
|