diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst index 447b2739d4..f82a0553dd 100644 --- a/hypothesis-python/RELEASE.rst +++ b/hypothesis-python/RELEASE.rst @@ -1,11 +1,9 @@ RELEASE_TYPE: minor -Since :ref:`v6.27.1` the backing data structure of -:func:`~hypothesis.register_random` is a :class:`weakref.WeakKeyDictionary`. As a -consequence, passing an unreferenced object to :func:`~hypothesis.register_random` will -have no affect on Hypothesis' tracking of RNG sources. This patch modifies -:func:`~hypothesis.register_random` to raise an error when it is passed an unreferenced -object, and to emit a warning when it looks like it was passed an object that is only -referenced within a temporary scope. These checks are skipped by PyPy's interpreter. -The type annotation of :func:`~hypothesis.register_random` was also widened to permit -structural subtypes of ``random.Random``. +:func:`~hypothesis.register_random` has used :mod:`weakref` since :ref:`v6.27.1`, +allowing the :class:`~random.Random`-compatible objects to be garbage-collected when +there are no other references remaining in order to avoid memory leaks. +We now raise an error or emit a warning when this seems likely to happen immediately. + +The type annotation of :func:`~hypothesis.register_random` was also widened so that +structural subtypes of :class:`~random.Random` are accepted by static typecheckers. diff --git a/hypothesis-python/docs/changes.rst b/hypothesis-python/docs/changes.rst index 409fb7d4bf..12731f70bd 100644 --- a/hypothesis-python/docs/changes.rst +++ b/hypothesis-python/docs/changes.rst @@ -1181,7 +1181,7 @@ This patch makes the :command:`hypothesis codemod` ------------------- This patch changes the backing datastructures of :func:`~hypothesis.register_random` -and a few internal caches to use :class:`weakref.WeakKeyDictionary`. This reduces +and a few internal caches to use :class:`weakref.WeakValueDictionary`. This reduces memory usage and may improve performance when registered :class:`~random.Random` instances are only used for a subset of your tests (:issue:`3131`).