Title: Change names of builtin types exposed in the types module · Issue #100129 · python/cpython · GitHub
Open Graph Title: Change names of builtin types exposed in the types module · Issue #100129 · python/cpython
X Title: Change names of builtin types exposed in the types module · Issue #100129 · python/cpython
Description: Some builtin types (like int, range, map) are exposed in the builtins module under their names. int.__name__ is "int" and int.__module__ is "builtins". getattr(sys.modules[int.__module__], int.__name__) is int Other builtin types are exp...
Open Graph Description: Some builtin types (like int, range, map) are exposed in the builtins module under their names. int.__name__ is "int" and int.__module__ is "builtins". getattr(sys.modules[int.__module__], int.__na...
X Description: Some builtin types (like int, range, map) are exposed in the builtins module under their names. int.__name__ is "int" and int.__module__ is "builtins". getattr(sys.modules[int._...
Opengraph URL: https://github.com/python/cpython/issues/100129
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Change names of builtin types exposed in the types module","articleBody":"Some builtin types (like `int`, `range`, `map`) are exposed in the `builtins` module under their names. `int.__name__` is \"int\" and `int.__module__` is \"builtins\". `getattr(sys.modules[int.__module__], int.__name__) is int`\r\n\r\nOther builtin types are exposed in the `types` module, but their `__module__` attribute is still \"builtins\", and their `__name__` attribute is different from the name under which they are accessible in the `types` module. The relation between names is not obvious, when you see `\u003cclass 'builtin_function_or_method'\u003e`, it is hard to defer that it is `types.BuiltinFunctionType`.\r\n\r\nAs result, these types cannot be pickled:\r\n```pycon\r\n\u003e\u003e\u003e pickle.dumps(types.ClassMethodDescriptorType)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n_pickle.PicklingError: Can't pickle \u003cclass 'classmethod_descriptor'\u003e: attribute lookup classmethod_descriptor on builtins failed\r\n```\r\n\r\nI propose to change attributes `__module__`, `__name__` and `__qualname__` of all builtin types exposed in the `types` modules so that they will match names under which they are accessible.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-100130\n* gh-100142\n* gh-100405\n* gh-100406\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/serhiy-storchaka","@type":"Person","name":"serhiy-storchaka"},"datePublished":"2022-12-09T08:42:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/100129/cpython/issues/100129"}
| 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:7f5854da-16ac-90e5-9a7a-90a8c3dfe400 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B6C:9B645:BD1E20:10950E8:6968DB29 |
| html-safe-nonce | 40be336031adb19213d045e4de02f66a69d68af4ff4d23a982144cf13061df87 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjZDOjlCNjQ1OkJEMUUyMDoxMDk1MEU4OjY5NjhEQjI5IiwidmlzaXRvcl9pZCI6IjEwNjAzMDg1NDI0NTYxMjYyNDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e7747f4da272a027c476c7a0622c0f9722706a7d03ba3ff666c8522225c1bbc5 |
| hovercard-subject-tag | issue:1486333813 |
| 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/100129/issue_layout |
| twitter:image | https://opengraph.githubassets.com/846565b4eeda5755a93bbe3677d8f109f78edda1f962099245234ca8bd092332/python/cpython/issues/100129 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/846565b4eeda5755a93bbe3677d8f109f78edda1f962099245234ca8bd092332/python/cpython/issues/100129 |
| og:image:alt | Some builtin types (like int, range, map) are exposed in the builtins module under their names. int.__name__ is "int" and int.__module__ is "builtins". getattr(sys.modules[int.__module__], int.__na... |
| 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 | 3c4e9f2fc1db52c609205138be6a397cfde4574cb54d53015014de30dd49f27e |
| 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 | 1fb1ea11f8c37dd4dd50347cca70d89824e93788 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width