Title: The data model and built-in types references disagree regarding ``sort()`` · Issue #138562 · python/cpython · GitHub
Open Graph Title: The data model and built-in types references disagree regarding ``sort()`` · Issue #138562 · python/cpython
X Title: The data model and built-in types references disagree regarding ``sort()`` · Issue #138562 · python/cpython
Description: Documentation The data model and built-in types reference are inconsistent regarding whether sort() should be an expected mutable sequence method. This was noted by @serhiy-storchaka during review of #138474. The data model, in 'Emulatin...
Open Graph Description: Documentation The data model and built-in types reference are inconsistent regarding whether sort() should be an expected mutable sequence method. This was noted by @serhiy-storchaka during review ...
X Description: Documentation The data model and built-in types reference are inconsistent regarding whether sort() should be an expected mutable sequence method. This was noted by @serhiy-storchaka during review ...
Opengraph URL: https://github.com/python/cpython/issues/138562
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The data model and built-in types references disagree regarding ``sort()``","articleBody":"# Documentation\n\nThe data model and built-in types reference are inconsistent regarding whether `sort()` should be an expected mutable sequence method. This was noted by @serhiy-storchaka during review of #138474.\n\nThe data model, in ['Emulating container types'](https://docs.python.org/dev/reference/datamodel.html#emulating-container-types) states:\n\n\u003e Mutable sequences should provide methods [...] and sort(), like Python standard list objects.\n\nThe built-in types reference, in ['Mutable Sequence Types'](https://docs.python.org/3.12/library/stdtypes.html#mutable-sequence-types) stated[^1]:\n\n\u003e The operations in the following table are defined on mutable sequence types\n\nwith `sort()` not included. Indeed, in `stdtypes.rst`, [`list.sort()`](https://docs.python.org/3/library/stdtypes.html#list.sort) is documented as an 'additional method', beyond the mutable sequence interface.\n\n-----------------------\n\nRelevant history:\n\n* `sort()` was added to the datamodel in 83b2f8ad3ddc340d203bc4e5d8a9765d70974579 (23/7/1998), and with the text effectively unchanged since.\n* `sort()` was removed from the table in `stdtypes.rst` in 273069cf7d79293fa0c2cca7fe6ab386a4e5c02a (20/8/2012).\n* A note that `bytes` (now `bytearray`) objects do not support `sort()` was added to the table in 226878cba507cff4b6ce094063682d0b0b53cbb9 (31/8/2007). Before this, support for `sort()` was unqualified in `stdtypes.rst`.\n\n----------------------\n\nOf the standard library sequence types, the only ones that implement a `sort()` method are `list`, `collections.UserList`, and `multiprocessing.managers.BaseListProxy`.\n\nGiven all of this, I propose that we update the data model to remove the reference to `sort()` as an expected sequence method. I think that this is the most pragmatic solution.\n\n\n[^1]: before the recent PR\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-138563\n* gh-138760\n* gh-140676\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/AA-Turner","@type":"Person","name":"AA-Turner"},"datePublished":"2025-09-05T20:53:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/138562/cpython/issues/138562"}
| 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:ad82b1cb-44f9-f55f-3ce7-b31fedb1d8ab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A084:145B07:1B74F:25F28:696A164C |
| html-safe-nonce | 4b91f2f7d00eba791538440d29960a682564a333d66477fe47c1881befe95739 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDg0OjE0NUIwNzoxQjc0RjoyNUYyODo2OTZBMTY0QyIsInZpc2l0b3JfaWQiOiI3NjAyNjQ1Njk4MzE4MzA4OTQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 98790fc46b4f100651105810340e2d972815d38f1b29b2ffdbcc20d8a036f67a |
| hovercard-subject-tag | issue:3388748499 |
| 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/138562/issue_layout |
| twitter:image | https://opengraph.githubassets.com/45b347e3edee9a7b15eafda5b527619468aea89d4387b19f70fe8be7ae416bd9/python/cpython/issues/138562 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/45b347e3edee9a7b15eafda5b527619468aea89d4387b19f70fe8be7ae416bd9/python/cpython/issues/138562 |
| og:image:alt | Documentation The data model and built-in types reference are inconsistent regarding whether sort() should be an expected mutable sequence method. This was noted by @serhiy-storchaka during review ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AA-Turner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 34a52bd10bd674f68e5c1b6b74413b79bf2ca20c551055ace3f7cdd112803923 |
| 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 | e8bd37502700f365b18a4d39acf7cb7947e11b1a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width