As of 3.12 `_lsprof` no longer calls `_PyEval_SetProfile` making `sys.getprofile()` useless with `cProfile`
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Starting in 3.12 with the addition of sys.monitoring, _lsprof, specifically in profiler_enable, no longer calls _PyEval_SetProfile.
Very specifically, this impacts previous functionality where python -m cProfile -m whatever would result in sys.setprofile() being called, and subsequently the whatever module could access the profiler object via sys.getprofile()
To my knowledge this is now completely impossible as sys.monitoring provides no meaningful way to access the profiler object.
In my particular use case, profiling could be enabled within the application, or if python -m cProfile was used, the existing profiler could be used allowing profiling to happen earlier than the enablement point of cProfile within the application.
Something to the effect of:
p = sys.getprofile()
if p is None:
p = cProfile.Profile()
p.enable()
CPython versions tested on:
3.13
Operating systems tested on:
Linux
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず _lsprof の profiler_enable の動作と _PyEval_SetProfile との関係を追跡し、次に 3.11 と 3.12 における python -m cProfile -m whatever の動作を比較します。sys.getprofile()、cProfile、sys.monitoring がどのように連携するかを確認します。3.12 以降の monitoring 設計を壊すことなく、意図された profiler オブジェクトにアクセスできる状態になれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100