GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-150942: Optimize stringlib split/splitlines with _PyList_AppendTakeRef by danielKim614 · Pull Request #155922 · python/cpython Conversation
Contributor
Append result items to the output list with Microbenchmarks
Benchmark script"""Microbenchmark str/bytes split / rsplit / splitlines (result-list building).""" import pyperf # Many small pieces (>12): exercises the append path after the 12-slot prealloc. import pyperf # Many small pieces (>12): exercises the append path after the 12-slot prealloc. STR_MANY = "abc " * 10_000 # .split(" ") -> 10001 pieces STR_WS = "word " * 10_000 # .split() whitespace variant BYTES_MANY = b"abc " * 10_000 # bytes.split LINES = "line\n" * 10_000 # .splitlines(): SPLIT_APPEND for every line # Controls STR_FEW = "a b c d e f g h i j" # 10 pieces: stays in the SET_ITEM prealloc path STR_BIG = ("x" * 4096 + " ") * 250 # large pieces: copy-dominated def bench_method(loops, obj, name, *args): method = getattr(obj, name) range_it = range(loops) t0 = pyperf.perf_counter() for _ in range_it: method(*args) return pyperf.perf_counter() - t0 runner = pyperf.Runner() runner.bench_time_func("str_split_10k_pieces", bench_method, STR_MANY, "split", " ") runner.bench_time_func("str_split_whitespace_10k", bench_method, STR_WS, "split") runner.bench_time_func("str_splitlines_10k", bench_method, LINES, "splitlines") runner.bench_time_func("bytes_split_10k_pieces", bench_method, BYTES_MANY, "split", b" ") runner.bench_time_func("str_split_10_pieces_ctl", bench_method, STR_FEW, "split", " ") runner.bench_time_func("str_split_large_pieces_ctl", bench_method, STR_BIG, "split", " ")
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @corona10 for commit f3fd338 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F155922%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.