Make the evidence travelLesson 29 of 30 · 8 min

Your browser is the instrument

Collect and export a paired timing record with correctness checks and explicit boundaries.

Now collect real elapsed times. Compare membership checks in a Python list and a set using the same integers and queries. Both must return the same hit count. A is the list; B is the set. The clock measures only the lookup loop, excluding construction and query generation.

Before starting the timer, the code runs the lookup task once per method to check that both return the same count. In each timed pair it shuffles which method goes first and records both times. These pairs share one Python runtime on one device. Separate sessions are needed to study variation between sessions.

Run the code with this tab visible. Record your device, then use Export run in the result tools to keep the exact code and times.

Name the timed boundary
Outside the timer

Build list & set

Generate matching queries

Inside the timer

Run the lookup loop

Return the same hit count

The reference diagram shows the published timing procedure. The timer covers the lookup loop. Construction and query generation happen before it. Both methods must return the same hit count. All 12 blocks share one runtime and device, so independence needs a separate justification.

Which costs would a one-off job need to include that this lookup-only timer excludes?

Write a prediction (optional)

Run the prepared example

This page puts the example in the Python editor. Select Run Python with the code unchanged.

Measured at execution

Editor tools
About Python ↗

Ctrl+Enter or ⌘+Enter runs the code.

Set block_count in the editor. Before you run, open Write a prediction above and record the block count and smallest useful percentage reduction.

What to compare

Use run_id and order to identify each pair. Compare a_ms (list) and b_ms (set) within each row. Which work falls inside the timer? The published example output comes from a different machine.

Published example output

The site ran the original code to produce this reference. Build environment ↗

MEASURED: local Python lookups (construction excluded).
Paired blocks share one runtime; independence is not established.
run_id,order,a_ms,b_ms
block-1,AB,3.005869,0.017450
block-2,AB,3.065305,0.016080
block-3,BA,3.028468,0.016047
block-4,AB,2.996969,0.015981
block-5,BA,3.063101,0.024765
block-6,BA,3.021647,0.016148
block-7,BA,2.997645,0.017065
block-8,AB,3.027307,0.016065
block-9,BA,2.990310,0.015655
block-10,AB,2.994642,0.016010
block-11,BA,3.058360,0.015729
block-12,BA,3.023695,0.015656

The original timer covers the lookup loop after construction. Each pair uses the same queries and code checks both methods return the same number of hits. These pairs share one session.

Change and run again

In the Python editor, change include_set_construction = False to include_set_construction = True. Select Run Python again. Check that the MEASURED line names the new boundary. Compare b_ms with your first run. Which work did you add for B, and what check still keeps the lookup task equivalent? Return to the Python editor

What this example supports. Pyodide executes real CPython in WebAssembly. These browser timings do not measure a native Python deployment, and timer precision can limit very short B readings.

Try a fresh case

You export twelve blocks from one browser session. What is a justified scope statement?

Choose an answer

Hints for this question
  1. Name the machine, runtime and timing boundary.
  2. Ask what changes between rows and what they share.
Your notes