← 返回首页
Add C API for importing an attribute from a module · Issue #93741 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Add C API for importing an attribute from a module #93741

New issue
New issue

Description

It is common (more than 30 cases) in the C code to access a function or a variable from other module. For example:

functools = PyImport_ImportModule("functools"); if (!functools) goto error; st->partial = PyObject_GetAttrString(functools, "partial"); Py_CLEAR(functools);

I propose to add a private helper function which combines PyImport_ImportModule() and PyObject_GetAttrString().

st->partial = _PyImport_GetModuleAttrString("functools", "partial");

It will save 4-6 lines of code and a variable on every use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.