Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize simple get/set operations in __getitem__ and __setitem__
these basic operations are very common so optimisation is warranted here. micro-benchmarks show a 3× speed-up for __getitem__ on a small dictionary, and a 2× speed-up for __setitem__. before: $ python -m timeit -r10 -s 'import sanest; d = sanest.dict(a=1, b=2, c=3)' 'd["a"]' 1000000 loops, best of 10: 1.55 usec per loop $ python -m timeit -r10 -s 'import sanest; d = sanest.dict(a=1, b=2, c=3)' 'd["a"] = "foo"' 100000 loops, best of 10: 2.24 usec per loop after: $ python -m timeit -r10 -s 'import sanest; d = sanest.dict(a=1, b=2, c=3)' 'd["a"]' 1000000 loops, best of 10: 0.409 usec per loop $ python -m timeit -r10 -s 'import sanest; d = sanest.dict(a=1, b=2, c=3)' 'd["a"] = "foo"' 1000000 loops, best of 10: 1.05 usec per loop due to earlier refactoring, previous "fast code paths" were dropped in these commits: 24e439e __getitem__ d3aa993 __setitem__ ...but now it is time to optimise those basic cases again. :)
- Loading branch information