GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement `frozendict` for `partialobject` in functools module · Issue #145478 · python/cpython

Implement frozendict for partialobject in functools module #145478

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Implement frozendict for partialobject in functools module#145478
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@brijkapadia
brijkapadia
opened on Mar 3, 2026
Issue body actions

Feature or enhancement

Proposal:

After discussion on PR #145362, it became clear that there are many possibilities for unintended mutations in the partialobject in Module/_functoolsmodule.c, particularly for the kw dictionary for keywords. Thus, changing kw to be a frozendict could prevent any unintended consequences.

Additionally, right now, the keys of kw could be an arbitrary PyObject, leading to unintended code execution if they are not strings. Thus, enforcing that the entries are strings could solve any future problems (similar to what happened in #145362).

Lastly, Issue #145446 also makes sure that there are no unintended mutations in the functools internals for free-threading, but changing to using a frozendict would be a more robust solution.

I will work on this and create a PR in the next couple of days. I will wait until #145446 is resolved to avoid any conflicts.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

#145362 (comment)

Linked PRs

  • gh-145478: Implement frozendict into functools.partial #145960

Activity

  1. brijkapadia
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Mar 3, 2026
  2. StanFromIreland
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Mar 3, 2026
  3. rhettinger commented on Mar 3, 2026

    @rhettinger
    rhettinger
    on Mar 3, 2026
    Contributor
    More actions

    This sounds like a reasonable approach. Immutable dictionaries can provide early detection or prevention for a number of subtle problems, especially those arising from free-threading.

    Reacted by Brij Kapadia
  4. brijkapadia commented on Mar 12, 2026

    @brijkapadia
    brijkapadia
    on Mar 12, 2026
    ContributorAuthor
    More actions

    Update: While I was working on this issue, I found that it would be convenient to have a way to convert a frozendict to a dict since a normal keywords dictionary is needed when calling functions. As such, I am waiting to create a PR until #145531 is merged.

  5. vstinner commented on Mar 12, 2026

    @vstinner
    vstinner
    on Mar 12, 2026
    Member
    More actions

    it would be convenient to have a way to convert a frozendict to a dict

    Currently, you can use dict = PyObject_CallOneArg((PyObject*)&PyDict_Type, frozendict); which calls the dict constructor. In my PR gh-145531, I proposed adding PyAnyDict_AsNewDict() function for that.

    Reacted by Brij Kapadia
  6. brijkapadia
    added a commit that references this issue on Mar 15, 2026

    pythongh-145478: Implement `frozendict` into `functools.partial`

    cdb948f
  7. brijkapadia
    closed this as not plannedon Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.