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

Made SimpleTestCase client attributes cached properties. #14257

Closed

Conversation

adamchainz
Copy link
Sponsor Member

This avoids instantiating them in test cases that don't need them.

This avoids instantiating them in test cases that don't need them.
@adamchainz
Copy link
Sponsor Member Author

adamchainz commented Apr 13, 2021

The saving here is pretty small - about 3 microseconds per test (that uses neither client):

In [2]: %timeit Client(), AsyncClient()
3.36 µs ± 28.8 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

That can add up though, and it could be larger in custom test client classes.

@nessita
Copy link
Contributor

nessita commented Apr 21, 2023

Hello @adamchainz, quick question, shouldn't we provide setters for these new properties to ensure this change is backwards compatible? Thanks!

@adamchainz
Copy link
Sponsor Member Author

I think we can close this one for now, it's not a huge optimization.

@adamchainz adamchainz closed this May 18, 2023
@adamchainz adamchainz deleted the test_clients_cached_properties branch May 18, 2023 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants