Skip to content

Add eval frame FFI bindings#6195

Open
adamgerhant-ai wants to merge 3 commits into
PyO3:mainfrom
adamgerhant-ai:eval-frame-ffi
Open

Add eval frame FFI bindings#6195
adamgerhant-ai wants to merge 3 commits into
PyO3:mainfrom
adamgerhant-ai:eval-frame-ffi

Conversation

@adamgerhant-ai

@adamgerhant-ai adamgerhant-ai commented Jul 7, 2026

Copy link
Copy Markdown

Adds FFI bindings for _PyInterpreterState_GetEvalFrameFunc, _PyInterpreterState_SetEvalFrameFunc, and _PyFrameEvalFunction.

In 3.11 _PyInterpreterState_GetEvalFrameFunc returns _PyEval_EvalFrameDefault if it is NULL, so the Option is removed from the return type.

Would it be acceptable to expose _PyEval_EvalFrameDefault in this PR since it may be required by older versions?

@mejrs

mejrs commented Jul 7, 2026

Copy link
Copy Markdown
Member

These were removed in #5711

@adamgerhant-ai

Copy link
Copy Markdown
Author

I am using these functions for a custom Python interpreter function hook. This is a useful API to expose to inject code in older versions which do not have sys.monitoring.

A simple search on Github of " = _PyInterpreterState_GetEvalFrameFunc" shows hundreds of usages, so I think it is reasonable for PyO3 to expose this.

@codspeed-hq

codspeed-hq Bot commented Jul 10, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 25.79%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 139 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
into_u128_max 1.5 µs 2 µs -25.79%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing adamgerhant-ai:eval-frame-ffi (4b14495) with main (8fcf8fc)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants