Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.15t
3.14t
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 10 additions & 3 deletions rounds/1_histogram/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading