Skip to content
This repository was archived by the owner on Oct 14, 2018. It is now read-only.

Conversation

@wojcikstefan
Copy link

Master branch:

In [3]: %timeit pyzipcode.ZipCodeDatabase().find_zip(state='CA')
10 loops, best of 3: 32 ms per loop

This PR:

In [2]: %timeit pyzipcode.ZipCodeDatabase().find_zip(state='CA')
10 loops, best of 3: 25.6 ms per loop

In [3]: %timeit pyzipcode.ZipCodeDatabase().find_zip(state='CA', exact=True)
100 loops, best of 3: 14.3 ms per loop

In [4]: %timeit pyzipcode.ZipCodeDatabase().find_zip(state='CA', exact=True, limit=1)
1000 loops, best of 3: 273 us per loop

The code is a bit less readable, but the performance gains are significant, especially if you don't need all the zip codes for a given city/state (hence the limit) and you're searching for an exact match.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants