From 27f3f7d94fc3f45fc590d20374578f4ae1c337fe Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Fri, 16 May 2025 23:01:07 +0100 Subject: [PATCH 1/3] Reword --- Doc/faq/design.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index e2710fab9cf800..0541213381b473 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -422,8 +422,10 @@ two to the directory. Tuples are immutable, meaning that once a tuple has been created, you can't replace any of its elements with a new value. Lists are mutable, meaning that -you can always change a list's elements. Only immutable elements can be used as -dictionary keys, and hence only tuples and not lists can be used as keys. +you can always change a list's elements. Only hashable objects can be used as +dictionary keys. Most immutable types are hashable, which is why tuples, but +not lists, can be used as keys. Note, however, that a tuple is only hashable +if all of its elements are hashable. How are lists implemented in CPython? From fdf53d923d376eb0b760b23696c90de2366f64c0 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Sat, 17 May 2025 08:32:09 +0100 Subject: [PATCH 2/3] Glossary link --- Doc/faq/design.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index 0541213381b473..ae6ed2844f07f8 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -422,10 +422,10 @@ two to the directory. Tuples are immutable, meaning that once a tuple has been created, you can't replace any of its elements with a new value. Lists are mutable, meaning that -you can always change a list's elements. Only hashable objects can be used as -dictionary keys. Most immutable types are hashable, which is why tuples, but -not lists, can be used as keys. Note, however, that a tuple is only hashable -if all of its elements are hashable. +you can always change a list's elements. Only :term:`hashable` objects can +be used as dictionary keys. Most immutable types are hashable, which is why +tuples, but not lists, can be used as keys. Note, however, that a tuple is +only hashable if all of its elements are hashable. How are lists implemented in CPython? From 82a6e2cf9c131462f16713f3a164e3a739f93c4b Mon Sep 17 00:00:00 2001 From: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Date: Sat, 17 May 2025 08:44:01 +0100 Subject: [PATCH 3/3] More links --- Doc/faq/design.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/faq/design.rst b/Doc/faq/design.rst index ae6ed2844f07f8..c758c019ca437b 100644 --- a/Doc/faq/design.rst +++ b/Doc/faq/design.rst @@ -420,8 +420,8 @@ strings representing the files in the current directory. Functions which operate on this output would generally not break if you added another file or two to the directory. -Tuples are immutable, meaning that once a tuple has been created, you can't -replace any of its elements with a new value. Lists are mutable, meaning that +Tuples are :term:`immutable`, meaning that once a tuple has been created, you can't +replace any of its elements with a new value. Lists are :term:`mutable`, meaning that you can always change a list's elements. Only :term:`hashable` objects can be used as dictionary keys. Most immutable types are hashable, which is why tuples, but not lists, can be used as keys. Note, however, that a tuple is