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

Avoid importing Hypothesis, for reduced startup time #143

Open
Zac-HD opened this issue Mar 30, 2024 · 0 comments
Open

Avoid importing Hypothesis, for reduced startup time #143

Zac-HD opened this issue Mar 30, 2024 · 0 comments

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Mar 30, 2024

We currently have a chunk of code (below) to ensure that Hypothesis can make the Trio scheduler deterministic. python-trio/trio#2981 proposes moving that into Trio itself; after which we can delete it here and celebrate (slightly) faster import times for anyone who doesn't use Hypothesis.

try:
from hypothesis import register_random
except ImportError: # pragma: no cover
pass
else:
# On recent versions of Hypothesis, make the Trio scheduler deterministic
# even though it uses a module-scoped Random instance. This works
# regardless of whether or not the random_module strategy is used.
register_random(trio._core._run._r)
# We also have to enable determinism, which is disabled by default
# due to a small performance impact - but fine to enable in testing.
# See https://github.com/python-trio/trio/pull/890/ for details.
trio._core._run._ALLOW_DETERMINISTIC_SCHEDULING = True

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

No branches or pull requests

1 participant