MagicStack / MagicStack/immutables
Make empty mapping a singleton
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.2k
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
We might want to consider making the same optimization for empty mappings that CPython does for the builtin immutable types tuple and frozenset: make the empty mapping a singleton.
For reference, consider:
tuple() is tuple()
# True
frozenset() is frozenset()
# True
import immutables
immutables.Map() is immutables.Map()
# False
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 by locating the C implementation behind the Python immutables.Map() constructor and checking how empty maps are currently created. Confirm the singleton behavior with repeated empty-map construction, preserve normal mapping behavior, and add or update coverage so immutables.Map() is immutables.Map().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100