can python do some kernel stuff?

Ethan Furman ethan at
Wed Jun 4 00:41:28 CEST 2008

Andrew Lee wrote:

> Diez B. Roggisch wrote:
>> Andrew Lee schrieb:
>>> Diez B. Roggisch wrote:
>>>> What has that todo with kernel programming? You can use e.g. pygame 
>>>> to get keystrokes. Or under linux, read (if you are root) the 
>>>> keyboard input file - I've done that to support several keyboards 
>>>> attached to a machine.
>>>> And the original question: no, python can't be used as kernel 
>>>> programming language. Amongst other reasons, performance & the GIL 
>>>> prevent that.
>>>> Diez
>>> Of course you can code kernel routines in Python -- you are just 
>>> calling the underlying C interface.  The GIL means you have to 
>>> manage threadsafety on your own -- it doesn't imply kernel 
>>> programming can not be done.
>> I understood the OP's question as "can one program kernelspace 
>> routines in python". Which I don't think is possible. And I don't see 
>> how py-pf does that either.
>> Diez
> OP: "I am wondering if python can do some kernel coding that
> used to be the private garden of C/C++."
> The answer is yes.  IPC and py-pf are examples.  If you don't think of 
> packet filtering as kernel coding, I can understand.  But clearly the 
> Python interfaces to fork(), waitpid(), signal(), alarm() and so forth 
> are forays into the once private garden of C.

Being able to call routines in the kernel is *not* the same as kernel 
coding.  Calling C routines is *not* the same as kernel coding.  
Actually writing the routines that are to be called, and that constitute 
the kernel itself, *is* kernel coding.  And as wonderful as Python is, 
it is *not* for kernel coding.

Having just looked at Py-PF, it is *managing* the firewall, not 
implementing it.  Again, not kernel coding.

More information about the Python-list mailing list