Skip to content

Requirement for safety of cache_hash is stronger than documented #503

@gabbard

Description

@gabbard

The documentation states:

cache_hash (bool) – Ensure that the object’s hash code is computed only once and stored on the object. If this is set to True, hashing must be either explicitly or implicitly enabled for this class. If the hash code is cached, then no attributes of this class which participate in hash code computation may be mutated after object creation.

A reader could read this as meaning that only the local fields of this object should not be assigned to and that using this on any frozen class is okay. We should clarify that the object needs to be "deeply immutable" for this to be safe.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions