Skip to content

Optimize airport lookup methods with hash-based indexes and caching#198

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/audit-performance-improvements-again
Draft

Optimize airport lookup methods with hash-based indexes and caching#198
Copilot wants to merge 4 commits intomainfrom
copilot/audit-performance-improvements-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 27, 2025

Airport lookups were using O(n) linear scans through 6000+ airports. IATA/ICAO code lookups now use O(1) hash indexes. List methods now cache results.

Changes

  • find_by_iata_code: Direct hash lookup via parsed_data[iata_code] instead of all.find (6x faster)
  • find_by_icao_code: Lazy-loaded ICAO reverse index for O(1) lookup instead of all.find (7x faster)
  • iata_codes/icao_codes: Memoized results to eliminate redundant array allocation (333x and 463x faster respectively)

Performance Impact

# Before: 0.357s for 10k lookups
Airports.find_by_iata_code("LHR")

# After: 0.056s for 10k lookups (83% faster)
Airports.find_by_iata_code("LHR")

# Before: 0.031s for 1k calls
Airports.iata_codes

# After: 0.0001s for 1k calls (99.7% faster)
Airports.iata_codes

No API changes. Added tests to verify caching behavior.

Original prompt

Audit for potential performance improvements and apply fixes

Created from VS Code via the GitHub Pull Request extension.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 27, 2025 02:45
Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
…o_codes methods

Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
Co-authored-by: timrogers <116134+timrogers@users.noreply.github.com>
Copilot AI changed the title [WIP] Audit for potential performance improvements and apply fixes Optimize airport lookup methods with hash-based indexes and caching Oct 27, 2025
Copilot AI requested a review from timrogers October 27, 2025 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants