Title: Typos in garbage collector docs · Issue #157724 · python/cpython · GitHub
Open Graph Title: Typos in garbage collector docs · Issue #157724 · python/cpython
X Title: Typos in garbage collector docs · Issue #157724 · python/cpython
Description: Documentation Hello Python team! Thanks so much for everything you do! It seems there are a few typos and possibly unclear statements about memory usage in the InternalDocs garbage collector page (hopefully reporting it is useful to the ...
Open Graph Description: Documentation Hello Python team! Thanks so much for everything you do! It seems there are a few typos and possibly unclear statements about memory usage in the InternalDocs garbage collector page (...
X Description: Documentation Hello Python team! Thanks so much for everything you do! It seems there are a few typos and possibly unclear statements about memory usage in the InternalDocs garbage collector page (...
Opengraph URL: https://github.com/python/cpython/issues/157724
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Typos in garbage collector docs","articleBody":"### Documentation\n\nHello Python team!\n\nThanks so much for everything you do!\nIt seems there are a few typos and possibly unclear statements about memory usage in the InternalDocs garbage collector page (hopefully reporting it is useful to the team; I would have fixed the typos and the bad L2 cache size, e.g. where the Python team has written 6GB instead of MB, except that there appear also to be possible conceptual issues so I figured I should ask here.)\n\nIn describing the Python garbage collector, the Internal Docs at \nhttps://github.com/python/cpython/blob/5539c2a5437acc4f4719aabac375368e0d310bd9/InternalDocs/garbage_collector.md?plain=1#L299 mention:\n> Pragmatically, it's important to note that no recursion is required by any of this,\n> and **neither does it in any other way require additional memory proportional to the\nnumber of objects**, number of pointers, or the lengths of pointer chains. \n> Apart from `O(1)` storage for internal C needs, **the objects themselves contain all the storage\nthe GC algorithms require**.\n\nThis seems to be making the claim that the extra data stored on the objects (e.g. the doubly linked list bidirectional pointers used for GC) are the only O(n) storage used by the GC in any of its algorithms.\n\nHowever, using a separate unbounded LIFO stack is mentioned:\nhttps://github.com/python/cpython/blob/5539c2a5437acc4f4719aabac375368e0d310bd9/InternalDocs/garbage_collector.md?plain=1#L536\n> Second, there is a LIFO stack, of unlimited size. When object references are found using tp_traverse, they are enqueued in the buffer if it is not full, otherwise they are pushed to the stack.\n\n(**Note also the typo, \"prefech\" should be \"prefetch\" at** https://github.com/python/cpython/blob/5539c2a5437acc4f4719aabac375368e0d310bd9/InternalDocs/garbage_collector.md?plain=1#L536 .)\n\nBut a LIFO stack of unbounded size (for any GC phase) does not seem consistent with the earlier claim (see above for link) that \"Apart from `O(1)` storage for internal C needs, **the objects themselves contain all the storage\nthe GC algorithms require**\"\n\n(Also a breadth first search is mentioned\nhttps://github.com/python/cpython/blob/5539c2a5437acc4f4719aabac375368e0d310bd9/InternalDocs/garbage_collector.md?plain=1#L294\n> This process is really a breadth first search over the object graph.\n).\n\n---\n\nNext, the display of text seems to be broken for most markdown viewers (including Github's) at https://github.com/python/cpython/blob/5539c2a5437acc4f4719aabac375368e0d310bd9/InternalDocs/garbage_collector.md?plain=1#L451\n\n> Indeed, it has\n> been remarked that doing a full collection every \u003cconstant number> of object\n> creations entails a dramatic performance degradation in workloads which consist\n> of creating and storing lots of long-lived objects (for example, building a large list\n> of GC-tracked objects would show quadratic performance, instead of linear as\n> expected). Using the above ratio, instead, yields amortized linear performance\n> in the total number of objects (the effect of which can be summarized thusly:\n> \"each full garbage collection is more and more costly as the number of objects\n> grows, but we do fewer and fewer of them\").\n\nwhere `\u003cconstant number>` doesn't display on GitHub's markdown viewer (so it is showing instead as \"doing a full collection **every of** object creations\"):\n> Indeed, it has been remarked that doing a full collection every of object creations entails a dramatic performance degradation in workloads which consist of creating and storing lots of long-lived objects (for example, building a large list of GC-tracked objects would show quadratic performance, instead of linear as expected). \n\nSee the following screenshots:\n\n\u003cimg width=\"1920\" height=\"465\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/1f0e4a94-72f1-44e7-b452-f2a333fc2176\" />\n\u003cimg width=\"1920\" height=\"564\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/cd474c0f-fbe4-42ff-873d-125cbb1c173c\" />\n\n---\n\nFinally, at:\nhttps://github.com/python/cpython/blob/5539c2a5437acc4f4719aabac375368e0d310bd9/InternalDocs/garbage_collector.md?plain=1#L619\n\nspecifications for a machine used for testing are given:\n> AMD Ryzen 5 7600X, 64 GB RAM, 384 KB L1, 6 GB L2, 32 MB L3\n\n**where \"6 GB L2\" should be \"6 MB L2\" (off by ~1000x)** ( compare to AMD's listing also https://web.archive.org/web/20260918004211/https://www.amd.com/en/products/processors/desktops/ryzen/7000-series/amd-ryzen-5-7600x.html )\n\n---\n\nThanks so much!\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157733\n* gh-157879\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/willy-b","@type":"Person","name":"willy-b"},"datePublished":"2026-09-18T01:55:52Z","url":"https://github.com/python/cpython/issues/157724"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:ae77bf2f-f885-c58b-c70e-fca1ece5f2c0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED44:11EACE:33EBD16:455367B:6B01FA9B |
| html-safe-nonce | 484732540c154d7236c402125ced57e2516a3720cb6405d23765081c58720239 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDQ0OjExRUFDRTozM0VCRDE2OjQ1NTM2N0I6NkIwMUZBOUIiLCJ2aXNpdG9yX2lkIjoiNjI2MjQ0OTI2MTU1NjkyMzAzNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3a31cc2389a8add34aa4982bfcc6ad23f3c7863faca85600fd7ce92b9a0842a8 |
| hovercard-subject-tag | issue:5494701222 |
| 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/157724/issue_layout |
| twitter:image | https://opengraph.githubassets.com/54dd2f75ad9c52a443cd1258b0d847f592f5366d5e362686b82dd71fbaee6f7f/python/cpython/issues/157724 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/54dd2f75ad9c52a443cd1258b0d847f592f5366d5e362686b82dd71fbaee6f7f/python/cpython/issues/157724 |
| og:image:alt | Documentation Hello Python team! Thanks so much for everything you do! It seems there are a few typos and possibly unclear statements about memory usage in the InternalDocs garbage collector page (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | willy-b |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width