MagicStack / MagicStack/immutables

Make empty mapping a singleton

Open
#20 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.