RunestoneInteractive / RunestoneInteractive/thinkcspy
Section 12.1 Dictionaries: As of Python 3.7, dictionaries are ordered.
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 135
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
Yes, there is some unclear/vague language around dictionaries being ordered/unordered. In Section 12.1, second paragraph, the book reads:
"Dictionaries are a different kind of collection. They are Python’s built-in mapping type. A map is an unordered, associative collection. The association, or mapping, is from a key, which can be any immutable type, to a value, which can be any Python data object."
The bold text is vague. Maps (not in Python, but the generic hash map or hash table which Python dictionaries are built upon) are unordered, making this statement true. However, dictionaries are a slightly different implementation of hashmaps, which has been ordered as of Python 3.7:
"the insertion-order preservation nature of dict objects has been declared to be an official part of the Python language spec."
The chapter goes on to discuss this unordered nature, which is now also false (it may also appear in later sections, but I did not comb them all):
"The order of the pairs may not be what you expected. Python uses complex algorithms, designed for very fast access, to determine where the key-value pairs are stored in a dictionary. For our purposes we can think of this ordering as unpredictable."
The order will always be insertion-ordered now, and is predictable.
Describe the solution you'd like
Either clarification of when the book is a) describing a generic hashmap/hashtable/map, or a specific Python dictionary; or b) removal of the language about dictionaries being unordered. I believe the former is a better solution, as it will matter to students after this introduction to Python, such as when they learn hash tables in a Data Structures course.
Additional context
Link to the exact text
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Section 12.1 on the linked dictionaries_dictionaries.html page and locate its source in the repository. Compare the statements about dictionary ordering with the Python 3.7 documentation, then clarify whether each passage describes generic maps or Python dictionaries. Update the relevant wording and verify the rendered section and any nearby references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100