Skip to content

Add free-threaded Python (PEP 703) support #256

Description

@fedemengo

The three C extensions (_input, _uinput, _ecodes) have no shared mutable global state, so there are no data races to fix. Supporting free-threaded Python (3.13+ nogil) is essentially a no-op correctness-wise — just add PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED) to the PyInit_ function of each extension (including the ecodes.c generator). Without this, importing evdev in a free-threaded build silently re-enables the GIL for the whole interpreter.

As a follow-up, wrapping blocking read()/ioctl() calls in Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS would allow true parallelism across threads reading different devices.

Happy to open a PR if there's interest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions