FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-152546: Refactor `mappingproxy.__new__` to use `PyDictProxy_New` by sobolevn · Pull Request #152547 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
42 changes: 16 additions & 26 deletions Objects/descrobject.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1253,32 +1253,6 @@ mappingproxy_check_mapping(PyObject *mapping)
return 0;
}

/*[clinic input]
@classmethod
mappingproxy.__new__ as mappingproxy_new

mapping: object

Read-only proxy of a mapping.
[clinic start generated code]*/

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)
{
Expand All @@ -1295,6 +1269,22 @@ PyDictProxy_New(PyObject *mapping)
return (PyObject *)pp;
}

/*[clinic input]
@classmethod
mappingproxy.__new__ as mappingproxy_new

mapping: object

Read-only proxy of a mapping.
[clinic start generated code]*/

static PyObject *
mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping)
/*[clinic end generated code: output=65f27f02d5b68fa7 input=c156df096ef7590c]*/
{
return PyDictProxy_New(mapping);
}


/* --- Wrapper object for "slot" methods --- */

Expand Down
Loading

Back | FazBrowse Home | New Git URL