[Python-Dev] PyOS_InputHook enhancement proposal
Michiel Jan Laurens de Hoon
mdehoon at ims.u-tokyo.ac.jp
Thu Dec 9 05:47:01 CET 2004
PyOS_InputHook is a pointer to a function that is called periodically (ten
times per second) while Python is idle, for example, when waiting for a
user command. Python C extension modules can set this pointer to a hook
function defined in the extension module. For example, _tkinter.c makes
use of PyOS_InputHook to get messages delivered to its widgets.
A problem arises when two or more extension modules want to set
PyOS_InputHook. For example, the scientific plotting package pygist needs
PyOS_InputHook to get messages delivered to its graphics windows, and may
therefore conflict with the Python GUI IDLE, which uses Tkinter. Chaining
won't work, as it will fail when an extension module wants to remove its
My suggestion is therefore to replace PyOS_InputHook by two functions
PyOS_AddInputHook and PyOS_RemoveInputHook, and let Python keep track of
which hooks are installed. This way, an extension module can add a hook
function without having to worry about other extension modules trying
to use the same hook.
Any comments? Would I need to submit a PEP for this proposal?
--Michiel, U Tokyo.
Michiel de Hoon, Assistant Professor
University of Tokyo, Institute of Medical Science
Human Genome Center
4-6-1 Shirokane-dai, Minato-ku
More information about the Python-Dev