From e347c480d51b2cf0671470b522ba09e38a0e9e25 Mon Sep 17 00:00:00 2001 From: Patrick Kidger <33688385+patrick-kidger@users.noreply.github.com> Date: Thu, 17 Aug 2023 08:15:32 -0700 Subject: [PATCH] Hash is now stable across python runtimes --- jaxtyping/_import_hook.py | 5 ++++- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/jaxtyping/_import_hook.py b/jaxtyping/_import_hook.py index 21cca35..0aec718 100644 --- a/jaxtyping/_import_hook.py +++ b/jaxtyping/_import_hook.py @@ -51,6 +51,7 @@ import ast import functools as ft +import hashlib import sys from collections.abc import Sequence from importlib.abc import MetaPathFinder @@ -165,7 +166,9 @@ class _JaxtypingLoader(SourceFileLoader): def __init__(self, *args, typechecker, **kwargs): super().__init__(*args, **kwargs) self._typechecker = typechecker - self._typechecker_hash = str(abs(hash(self._typechecker))) + self._typechecker_hash = hashlib.md5( + self._typechecker.encode("utf-8") + ).hexdigest() def source_to_code(self, data, path, *, _optimize=-1): source = decode_source(data) diff --git a/pyproject.toml b/pyproject.toml index 168d3ae..66a316b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "jaxtyping" -version = "0.2.20" +version = "0.2.21" description = "Type annotations and runtime checking for shape and dtype of JAX arrays, and PyTrees." readme = "README.md" requires-python ="~=3.9"