From 365d32ff1c6d6feb9e15f0f645631c025c850db2 Mon Sep 17 00:00:00 2001 From: Dar Date: Wed, 13 May 2026 10:00:28 -0700 Subject: [PATCH 1/2] testing --- .python-version | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.python-version b/.python-version index d5629d4..a469d8f 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.15t +3.14t diff --git a/README.md b/README.md index 44e0723..6fab156 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A PyCon US 2026 hands-on tutorial. You optimize intentionally slow Python code across three rounds plus a team challenge, measuring every change with -[CodSpeed](https://codspeed.io). +[CodSpeed](https://codspeed.io)i... ## Rounds From cd40d6dfa849ec5b19d208e90758c2b0671000e7 Mon Sep 17 00:00:00 2001 From: Dar Date: Wed, 13 May 2026 10:16:03 -0700 Subject: [PATCH 2/2] Updated solution.py --- rounds/1_histogram/solution.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rounds/1_histogram/solution.py b/rounds/1_histogram/solution.py index dffbee5..e026614 100644 --- a/rounds/1_histogram/solution.py +++ b/rounds/1_histogram/solution.py @@ -4,11 +4,18 @@ passes out of the box. Replace the body of ``compute_histogram`` with your own faster implementation. """ +from collections import defaultdict def compute_histogram(path: str) -> dict[bytes, int]: + """Frequency of every 2-byte bigram in the file at ``path``.""" - # TODO: remove this delegation and write your own implementation here. - from .baseline import compute_histogram as _baseline + counts: dict[bytes, int] = defaultdict(int) + + with open(path, "rb") as f: + data = f.read() + + for i in range(len(data) - 1): + counts[data[i:i + 2]] += 1 - return _baseline(path) + return dict(counts)