Title: Unclear why iter_items should be favored over list_items · Issue #1775 · gitpython-developers/GitPython · GitHub
Open Graph Title: Unclear why iter_items should be favored over list_items · Issue #1775 · gitpython-developers/GitPython
X Title: Unclear why iter_items should be favored over list_items · Issue #1775 · gitpython-developers/GitPython
Description: In git.util.IterableObj, the list_items method recommends that iter_items be used instead, and begins to explain why, but it appears the actual explanation was never written: GitPython/git/util.py Lines 1255 to 1256 in 4023f28 :note: Fav...
Open Graph Description: In git.util.IterableObj, the list_items method recommends that iter_items be used instead, and begins to explain why, but it appears the actual explanation was never written: GitPython/git/util.py ...
X Description: In git.util.IterableObj, the list_items method recommends that iter_items be used instead, and begins to explain why, but it appears the actual explanation was never written: GitPython/git/util.py ...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/1775
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unclear why iter_items should be favored over list_items","articleBody":"In [`git.util.IterableObj`](https://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1237-L1271), the [`list_items`](https://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1248-L1261) method recommends that [`iter_items`](https://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1263-L1271) be used instead, and begins to explain why, but it appears the actual explanation was never written:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1255-L1256\r\n\r\nThe deprecated [`git.util.Iterable`](https://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1201-L1233) class has the same note in its [`list_items`](https://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1209-L1224) docstring:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1218-L1219\r\n\r\nIn both cases, the subsequent non-blank line in the docstring documents what the `list_items` method itself returns, so the continuation truly is missing. The intended continuation does not seem to me to be something that can be inferred from the docstring as a whole. For example, here's the whole `IterableObj.list_items` docstring:\r\n\r\nhttps://github.com/gitpython-developers/GitPython/blob/4023f28660e3a78ca9a83f03ca10b39780d32b0e/git/util.py#L1250-L1258\r\n\r\nIt may seem odd that, unlike #1712, I did not notice this when working on #1725. But I *think* the reason is not that the docstrings had made sense to me at that time, but instead that I had noticed the more minor (really, almost trivial) issue that perhaps the first paragraph should be split so that only its first sentence would be its summary line, decided to return to it later to consider that further, and then forgot about it.\r\n\r\nThe text \"Favor the iter_items method as it will\" appears to have been present, and its continuation absent, for as long as the surrounding code has been in GitPython. It was introduced in f4fa1cb along with the `Iterable` class itself.\r\n\r\nIn general, it may sometimes be preferable to obtain an iterator rather than a list or other sequence because it may not be necessary to materialize a collection just to iterate over it, and because unnecessary materialization can sometimes increase space usage. On the other hand, materialization guards against mutation of the original collection during iteration. But these are *completely general* ideas, not informed by the `list_items` docstrings nor even by any consideration specific to GitPython.\r\n\r\nMy guess is that the docstring intended to say something more specific, or at least to identify which general benefit of `iter_items` serves to recommend it. So I don't think I could propose a specific improvement to that documentation without insight into what was originally intended.","author":{"url":"https://github.com/EliahKagan","@type":"Person","name":"EliahKagan"},"datePublished":"2023-12-21T00:28:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/1775/GitPython/issues/1775"}
| 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:cf1689b1-4192-4112-bec9-f620357ae024 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 97C0:9F469:88BF06:B78DCE:69683258 |
| html-safe-nonce | a2da6fe2dbbb7ffc03126f2ebdfdd532aedea0ced9a6690f4ee1e07d4f68d499 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0MwOjlGNDY5Ojg4QkYwNjpCNzhEQ0U6Njk2ODMyNTgiLCJ2aXNpdG9yX2lkIjoiNTY0NzAyMTc4NzA3MzQ5MTU0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 04e78e24042d703a0a88278b9e94b606528b0cfccdc64ec50c4d6fd1827f1172 |
| hovercard-subject-tag | issue:2051485757 |
| 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/gitpython-developers/GitPython/1775/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d91c193c2be11f39901181c2e378815688292eb797877b1f2078eed9a70eb2e/gitpython-developers/GitPython/issues/1775 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d91c193c2be11f39901181c2e378815688292eb797877b1f2078eed9a70eb2e/gitpython-developers/GitPython/issues/1775 |
| og:image:alt | In git.util.IterableObj, the list_items method recommends that iter_items be used instead, and begins to explain why, but it appears the actual explanation was never written: GitPython/git/util.py ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | EliahKagan |
| hostname | github.com |
| expected-hostname | github.com |
| None | e25f416bb6d8a5f8624aad6cebc375ab2c50ac58f2175f32a7093325e66e5515 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| 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 | 62f32509ca504f5a4d99dec2769ceeb24353c334 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width