Closed BoboTiG closed 2 years ago
$ python -m timeit -n 1000000 -s "from hexbytes import HexBytes" "HexBytes(0)"
1000000 loops, best of 5: 1.260 usec per loop
1000000 loops, best of 5: 0.875 nsec per loop (-30.5 %)
I assume that usec
is wrong, or it got >1000x faster? 😆
$ python -m timeit -n 1000000 -s "from hexbytes import HexBytes" "HexBytes(0)" 1000000 loops, best of 5: 1.260 usec per loop 1000000 loops, best of 5: 0.875 nsec per loop (-30.5 %)
I assume that
usec
is wrong, or it got >1000x faster? laughing
I tried again, and indeed, I did a "small" mistake:
# From the master branch
$ python -m timeit -n 1000000 -s "from hexbytes import HexBytes" "HexBytes(0)"
1000000 loops, best of 5: 1.2 usec per loop
# From the branch of that PR
$ python -m timeit -n 1000000 -s "from hexbytes import HexBytes" "HexBytes(0)"
1000000 loops, best of 5: 906 nsec per loop
Quick benchmarks (first line is the original code, second is the patched one):
What was wrong?
Nothing.
How was it fixed?
Gut feeling.
I had to bypass mypy errors as they are not revelant.
To-Do
[x] Clean up commit history
[ ] Add entry to the release notes
Cute Animal Picture