Yury Selivanov <yseliva...@gmail.com> added the comment:
> Would there be too much overhead if allowing specification of a python > function that contextvars calls on context changes? Potentially yes, especially if we allow more than one context change callback. Allowing just one makes the API inflexible (what if you want to use two libraries from PyPI that both want to use the callback). Allowing multiple context change callbacks leads to complicated API. For extra context: context switches occur on every callback invocation in asyncio and there can be thousands of them per seconds (or even more). Adding any extra code to context switching code will noticeably degrade the performance. In general, I'd suggest patching the C library to make state management customizable (like CPython allows you to customize which memory allocator to use) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39660> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com