python / python/cpython

C API: Enable limited C API tests on Free Threading

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

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

tests topic-C-API
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Currently, the _testlimitedcapi extension module is not built with the limited C API on Free Threading which is misleading and defeats the purpose of this extension.

PEP 803 added Py_TARGET_ABI3T macro to Python 3.15 which makes it possible to build a C extension using the limited C API when using Free Threading. So I propose building _testlimitedcapi using Py_TARGET_ABI3T to test properly the limited C API on Free Threading.

One limitation is that Py_TARGET_ABI3T minimum version is Python 3.15, whereas _testlimitedcapi/<file>.c files target older Python versions. Anyway, we have to only define Py_TARGET_ABI3T on Free Threading, or define Py_LIMITED_API macro otherwise (build with GIL). Example:

#include "pyconfig.h"   // Py_GIL_DISABLED
#ifdef Py_GIL_DISABLED
#  define Py_TARGET_ABI3T 0x030f0000
#else
   // Need limited C API version 3.13 for Py_GetConstant()
#  define Py_LIMITED_API 0x030d0000
#endif
Linked PRs
  • gh-155570
  • gh-155693
  • gh-156052

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

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

はじめの一歩

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

調査の方向性

まず、issue で説明されている _testlimitedcapi/.c ソースと pyconfig.h マクロから始め、次に Free Threading 用に _testlimitedcapi がどのようにビルドされるかを調べます。_testlimitedcapi 拡張機能にある limited C API テストを確認し、Free Threading で Py_TARGET_ABI3T を使ってビルドおよび実行できることを確認するとともに、GIL ビルドでは Py_LIMITED_API が維持されることを確認します。

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

評価

技術スタック
c, python
領域
testing-qa
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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