python / python/cpython

Proposal to add gc_list_for_each macro

オープン
#133,058 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

interpreter-core pending type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Feature or enhancement

Proposal:

In the implementation of the reference cycle garbage collector, gc.c file, I have noticed that we use the following for-loop pattern over and over to traverse a PyGC_Head list:

for (gc = GC_NEXT(list); gc != list; gc = GC_NEXT(gc)) {
  /* ... */
}

However, in pycore_llist.h we avoided that by using llist_for_each macro as:

// Iterate over a list.
#define llist_for_each(node, head) \
    for (node = (head)->next; node != (head); node = node->next)

I propose adding a new macro as gc_list_for_each to the gc_list_xxx family to serve the same purpose:

#define gc_list_for_each(gc, list) \
    for (gc = GC_NEXT((list)); gc != (list); gc = GC_NEXT(gc))
Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、gc.c にある PyGC_Head の繰り返し走査パターンと、pycore_llist.h にある既存の llist_for_each マクロを確認します。提案されている gc_list_for_each マクロを gc_list_xxx ファミリーに追加し、参照サイクルのガベージコレクターが引き続きビルドでき、既存の動作に変更がないことを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c
領域
backend
issue の種類
機能追加
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。