Evidence type: simulation. Results are limited to the documented conditions.
The question
To locate a name among a million filenames, must a program inspect every name, or can it use an index prepared in advance?
Methods
Python generated four sets of unique virtual filenames: 1,000, 10,000, 100,000 and 1,000,000. We compared a sequential scan with a dictionary mapping exact names to positions. For each size, 20 positions were randomly selected using seed 20261119, and first-position, last-position and absent-name cases were added. Every case was measured five times, and both methods were required to return the same correct result. Files existed only in memory, not on a physical drive.
Figure 1. Schematic illustration, not measured data.
Observations
| Virtual filenames | Sequential scan (ms) | Dictionary lookup (ms/query) |
|---|---|---|
| 1,000 | 0.0155 | 0.000050 |
| 10,000 | 0.1235 | 0.000053 |
| 100,000 | 1.5573 | 0.000054 |
| 1,000,000 | 21.1757 | 0.000057 |
For 20 randomly selected positions, we took the median of five measurements per target, then the median across targets. Dictionary lookup was timed in batches of 1,000 and divided by the batch size. The timing methods differ; the ratio should not be presented as an exact software speedup.
Figure 2. Results obtained by executing the Python program; axes use different scales.
A first-position match can also be extremely fast for a sequential scan. Searching for a late or missing name requires more comparisons.
Figure 3. Search position affects sequential-scan timing.
Building the index was not free. A single timed construction took 0.17, 2.66, 44.80 and 320.27 ms across the four sizes, respectively. These are individual observations, not reliable mean build times.
Figure 4. One observed index-build time per size.
Conclusion and limitations
Under the explicitly defined conditions of in-memory exact-name matching, an existing dictionary index allowed fast repeated lookups, whereas the sequential scan depended on the number and position of entries. Index creation has an upfront cost. Everything uses filesystem information and change tracking, but is not implemented as this Python dictionary; Windows Search has its own indexing system. This experiment does not establish how much faster either real application is.
The executable code, timing records and environment details are supplied as attachments. AI assisted coding and editing. Independent third-party reproduction has not yet been performed.