Title: Add C API for importing an attribute from a module · Issue #93741 · python/cpython · GitHub
Open Graph Title: Add C API for importing an attribute from a module · Issue #93741 · python/cpython
X Title: Add C API for importing an attribute from a module · Issue #93741 · python/cpython
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...
Open Graph 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->pa...
X 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 err...
Opengraph URL: https://github.com/python/cpython/issues/93741
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add C API for importing an attribute from a module","articleBody":"It is common (more than 30 cases) in the C code to access a function or a variable from other module. For example:\r\n```c\r\n functools = PyImport_ImportModule(\"functools\");\r\n if (!functools)\r\n goto error;\r\n st-\u003epartial = PyObject_GetAttrString(functools, \"partial\");\r\n Py_CLEAR(functools);\r\n```\r\n I propose to add a private helper function which combines `PyImport_ImportModule()` and `PyObject_GetAttrString()`.\r\n```c\r\n st-\u003epartial = _PyImport_GetModuleAttrString(\"functools\", \"partial\");\r\n```\r\nIt will save 4-6 lines of code and a variable on every use.\r\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2022-06-12T09:32:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/93741/cpython/issues/93741"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2a5ba901-17b6-07e5-85af-acc9a46cd83a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD56:240939:961A87:C97BDC:69697DC2 |
| html-safe-nonce | 2dff7ede7cf0f5844634d66d57e007070edcf9ed9f3f689a5b4d7190e7f00644 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDU2OjI0MDkzOTo5NjFBODc6Qzk3QkRDOjY5Njk3REMyIiwidmlzaXRvcl9pZCI6IjI1NTk4MDA0MDI4MTAzMzg3NTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 07fb5077f1e6d6225d447ffa3d943cad6119f5bf0abd325354cf7d63d297b332 |
| hovercard-subject-tag | issue:1268524416 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/93741/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fee408d5e711cf49e60766f07e54eba3cbbbfdfe4892ce6f8e948283d294cbb7/python/cpython/issues/93741 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fee408d5e711cf49e60766f07e54eba3cbbbfdfe4892ce6f8e948283d294cbb7/python/cpython/issues/93741 |
| og:image:alt | 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->pa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | serhiy-storchaka |
| hostname | github.com |
| expected-hostname | github.com |
| None | f33e4b94c8824ab2b434d82a94139432fb5ebee9df4b75304140ad22508c4a77 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 48f380098b30acbb700b04f1724481ca10d574fc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width