Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Pluggable optimizer API #104584

Closed
Closed
Labels
3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage
@markshannon

Description

@markshannon

We need an API for optimizers to be plugged in to CPython.

The proposed model is that of client server, where the VM is the client and the optimizer is the server.
The optimizer registers with the VM, then VM calls the optimizer when hotspots are detected.

The API:

typestruct {OBJECT_HEADER;_PyInterpreterFrame*(*execute)(PyExecutorObject*self,_PyInterpreterFrame*frame,PyObject**stack_pointer);/* Data needed by the executor goes here, but is opaque to the VM */}PyExecutorObject;/* This would be nicer as an enum, but C doesn't define the size of enums */#definePY_OPTIMIZE_FUNCTION_ENTRY 1#definePY_OPTIMIZE_RESUME_AFTER_YIELD 2#definePY_OPTIMIZE_BACK_EDGE 4typedefuint32_tPyOptimizerCapabilities;typestruct {OBJECT_HEADER;PyExecutorObject*(*compile)(PyOptimizerObject*self,PyCodeObject*code,intoffset);PyOptimizerCapabilitiescapabilities;floatoptimization_cost;floatrun_cost;/* Data needed by the compiler goes here, but is opaque to the VM */}PyOptimizerObject;void_Py_Executor_Replace(PyCodeObject*code,intoffset,PyExecutorObject*executor);int_Py_Optimizer_Register(PyOptimizerObject*optimizer);

The semantics of aPyExecutorObject is that upon return from itsexecute function, the VM state will have advancedN instructions. WhereN is a non-negative integer.

Full discussion here:faster-cpython/ideas#380

This is not a replacement for PEP 523. That will need a PEP. We should get this working first, before we consider replacing PEP 523.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp