jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.44k stars 75 forks source link

Add struct `cache_hash` option #596

Closed jcrist closed 12 months ago

jcrist commented 12 months ago

If enabled, the hash value for a frozen struct instance will be computed at most once, and then stored on the instance for further reuse. For expensive hash computations this can result in improved performance at the cost of a small amount of memory use.

Fixes #591.