Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add requests.session to REST classes #141

Closed
wants to merge 1 commit into from
Closed

Add requests.session to REST classes #141

wants to merge 1 commit into from

Conversation

ronnie-llamado
Copy link
Member

Add a requests.session to APIConnection, TigerConnection and ESRILayer. Creates persistent HTTP connection to be reused when requesting from the same domain. Currently each GET request opens a new connections, transacts and then closes the connection.

Closes #140

@ronnie-llamado ronnie-llamado requested review from ljwolf and removed request for ljwolf May 4, 2021 23:13
@ronnie-llamado ronnie-llamado marked this pull request as draft May 4, 2021 23:13
@ronnie-llamado
Copy link
Member Author

The following code was used as a benchmark.

chicago = \
    cenpy.products.ACS(2017).from_place("Chicago, IL", level="tract", variables=["B00002*", "B01002H_001E"])

There were two noticeable changes:

  1. There were 9 less connections opened/closed.
  2. Using the timeit module, the refactor shaved ~3s on average from executing the code above.
original      (seconds) : [24.64, 27.20, 25.48, 23.19, 23.36, 24.66, 29.26, 25.37, 26.27, 22.84] : 25.23 (avg) 
with refactor (seconds) : [26.96, 19.80, 21.40, 23.00, 22.00, 19.68, 23.19, 20.46, 19.91, 25.15] : 22.16 (avg)

@ronnie-llamado ronnie-llamado closed this by deleting the head repository Dec 29, 2023
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.

Create persistent HTTP connection for REST connections
1 participant