diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..005d289 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "python.linting.banditEnabled": false, + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/bench_slicing.py b/bench_slicing.py new file mode 100644 index 0000000..f2e146e --- /dev/null +++ b/bench_slicing.py @@ -0,0 +1,16 @@ +def bytes_slice(): + """Slice using normal bytes""" + word = b'A' * 1000 + for i in range(1000): + n = word[0:i] + +def memoryview_slice(): + """Convert to a memoryview first.""" + word = memoryview(b'A' * 1000) + for i in range(1000): + n = word[0:i] + + +__benchmarks__ = [ + (bytes_slice, memoryview_slice, "Slicing with memoryview instead of bytes"), +]