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 — Refactor `mappingproxy_new_impl` method to use `PyDictProxy_New` · Issue #152546 · python/cpython

Refactor mappingproxy_new_impl method to use PyDictProxy_New #152546

New issue
Copy link
New issue
Copy link
Closed
Closed
Refactor mappingproxy_new_impl method to use PyDictProxy_New#152546
Copy link
Assignees
sobolevn
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Description

@sobolevn
sobolevn
opened on Jun 29, 2026
Issue body actions

They are located next to each other, use identical code.
They should be refactored to be the same thing:

cpython/Objects/descrobject.c

Lines 1265 to 1296 in 2670cb0

static PyObject *
mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping)
/*[clinic end generated code: output=65f27f02d5b68fa7 input=c156df096ef7590c]*/
{
mappingproxyobject *mappingproxy;
if (mappingproxy_check_mapping(mapping) == -1)
return NULL;
mappingproxy = PyObject_GC_New(mappingproxyobject, &PyDictProxy_Type);
if (mappingproxy == NULL)
return NULL;
mappingproxy->mapping = Py_NewRef(mapping);
_PyObject_GC_TRACK(mappingproxy);
return (PyObject *)mappingproxy;
}
PyObject *
PyDictProxy_New(PyObject *mapping)
{
mappingproxyobject *pp;
if (mappingproxy_check_mapping(mapping) == -1)
return NULL;
pp = PyObject_GC_New(mappingproxyobject, &PyDictProxy_Type);
if (pp != NULL) {
pp->mapping = Py_NewRef(mapping);
_PyObject_GC_TRACK(pp);
}
return (PyObject *)pp;
}

Linked PRs

  • gh-152546: Refactor mappingproxy.__new__ to use PyDictProxy_New #152547

Activity

  1. sobolevn
    self-assigned this
    on Jun 29, 2026
  2. sobolevn
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
    on Jun 29, 2026
  3. sobolevn
    added a commit that references this issue on Jun 30, 2026

    gh-152546: Refactor `mappingproxy.__new__` to use `PyDictProxy_New` (#…

    38df997
  4. sobolevn
    closed this as completedon Jun 30, 2026
  5. maurycy
    added a commit that references this issue on Jul 1, 2026

    Merge branch 'main' into maurycy/bye-abba

    da7d768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

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.