Tagged articles
2 articles
Page 1 of 1
Satori Komeiji's Programming Classroom
Satori Komeiji's Programming Classroom
Aug 9, 2024 · Fundamentals

What Makes an Object Hashable in Python and How Is Its Hash Computed?

An object is hashable in Python if it is immutable and implements __eq__, allowing it to serve as a dictionary key; the hash value is normally derived from the object's address unless __hash__ is overridden, and equal objects must share identical hash values, influencing dictionary indexing and collision handling.

custom __eq__custom __hash__dictionary
0 likes · 11 min read
What Makes an Object Hashable in Python and How Is Its Hash Computed?
Liulishuo Tech Team
Liulishuo Tech Team
Apr 13, 2018 · Fundamentals

Understanding Compiler Synthesis of Equatable and Hashable in Swift 4.1

This article explains how Swift 4.1's compiler can automatically synthesize Equatable and Hashable implementations, the necessary conditions, examples of enums and structs, the limitations of synthesis, and how developers can override or supplement the generated code for better performance and correctness.

EquatableSwiftSynthesis
0 likes · 8 min read
Understanding Compiler Synthesis of Equatable and Hashable in Swift 4.1