Title: Document the preferred style for API functions with three, four or five-way returns · Issue #1121 · python/devguide · GitHub
Open Graph Title: Document the preferred style for API functions with three, four or five-way returns · Issue #1121 · python/devguide
X Title: Document the preferred style for API functions with three, four or five-way returns · Issue #1121 · python/devguide
Description: Most C API functions either succeed or fail. Those functions return NULL/not-NULL or 0/-1. No problem there. However there are functions that can have three or more return kinds. For example, found/not-found/error, yield/return/raise, or...
Open Graph Description: Most C API functions either succeed or fail. Those functions return NULL/not-NULL or 0/-1. No problem there. However there are functions that can have three or more return kinds. For example, found...
X Description: Most C API functions either succeed or fail. Those functions return NULL/not-NULL or 0/-1. No problem there. However there are functions that can have three or more return kinds. For example, found...
Opengraph URL: https://github.com/python/devguide/issues/1121
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document the preferred style for API functions with three, four or five-way returns","articleBody":"Most C API functions either succeed or fail. Those functions return `NULL`/not-`NULL` or 0/-1. No problem there.\r\n\r\nHowever there are functions that can have three or more return kinds.\r\nFor example, `found/not-found/error`, `yield/return/raise`, or even `less-than/equal/greater-than/unordered/error` in the case of comparisons.\r\n\r\nFor those functions we want to return the kind as an `int`, setting any `PyObject *` results through an out pointer.\r\n\r\nThe devguide should document the preferred way to do this, to avoid endless debate for each new C API function.\r\n\r\nSee https://github.com/python/cpython/issues/105201#issuecomment-1578342058 for my preferred approach for three-way return values.\r\n\r\nFour and five way return values other than for comparisons are sufficiently uncommon that they can be dealt with on an individual basis.\r\n\r\nFor comparisons, a slightly strange [enum based on powers-of-two](https://github.com/python/cpython/blob/main/Include/internal/pycore_code.h#L469) is to be used for efficient selection of the desired result by masking.","author":{"url":"https://github.com/markshannon","@type":"Person","name":"markshannon"},"datePublished":"2023-06-22T10:06:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/1121/devguide/issues/1121"}
| 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:a69afae2-6769-f79d-c61d-bec70a58ae10 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E68E:159D04:29CE52:369654:696B3A68 |
| html-safe-nonce | 6fc0cdb59aa7f5104506fa947148dde2df055fe6c7c835a4f5115a184e427257 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjhFOjE1OUQwNDoyOUNFNTI6MzY5NjU0OjY5NkIzQTY4IiwidmlzaXRvcl9pZCI6IjgyOTMyMzMxMzc2NTQ5MDU0NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d5c74eae5780eb89b70b6ff783eddf44d477b2b3618f4f0b4ad58ce203238b9c |
| hovercard-subject-tag | issue:1769363491 |
| 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/devguide/1121/issue_layout |
| twitter:image | https://opengraph.githubassets.com/44232a60cf45f4295021eea915c6deb00799c4f9b3b28a4ebc8b72d85d9b5ede/python/devguide/issues/1121 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/44232a60cf45f4295021eea915c6deb00799c4f9b3b28a4ebc8b72d85d9b5ede/python/devguide/issues/1121 |
| og:image:alt | Most C API functions either succeed or fail. Those functions return NULL/not-NULL or 0/-1. No problem there. However there are functions that can have three or more return kinds. For example, found... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | markshannon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/devguide git https://github.com/python/devguide.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 63972479 |
| octolytics-dimension-repository_nwo | python/devguide |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 63972479 |
| octolytics-dimension-repository_network_root_nwo | python/devguide |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width