Skip to content

Graph: Add helper function to improve cython type inference#2210

Merged
WyattBlue merged 1 commit intoPyAV-Org:mainfrom
lgeiger:graph-simplify
Mar 23, 2026
Merged

Graph: Add helper function to improve cython type inference#2210
WyattBlue merged 1 commit intoPyAV-Org:mainfrom
lgeiger:graph-simplify

Conversation

@lgeiger
Copy link
Copy Markdown
Contributor

@lgeiger lgeiger commented Mar 23, 2026

_context_by_type.get("buffer", []) doesn't work nicely with cython and can't infer the return type. This introduces a small helper function which allows cython to infer the output type correctly and generate simpler code.

@cython.cfunc
def _register_context(self, ctx: FilterContext):
self._context_by_ptr[cython.cast(cython.long, ctx.ptr)] = ctx
self._context_by_name[ctx.ptr.name] = ctx
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_context_by_name is not used anywhere at the moment, so I think we can safely remove it

@WyattBlue WyattBlue merged commit c0f2947 into PyAV-Org:main Mar 23, 2026
8 checks passed
@lgeiger lgeiger deleted the graph-simplify branch March 23, 2026 14:17
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