Reimplenting Linux Kernel in Python

Phil Frost indigo at bitglue.com
Wed Oct 13 21:09:00 EDT 2004


On Wed, Oct 13, 2004 at 08:24:48PM -0300, Carlos Ribeiro wrote:
> ...
> 
> Now, let me re-state your question in a broader sense. Is it possible
> to write an OS using a language such as Python? Yes. But the resulting
> OS will surely be different from Linux -- by design it would be a
> completely different beast. Some parts would still be written in C and
> assembler, because it needs to access the hardware, and also for
> performance reasons. But an API could be devised to allow higher-level
> functions to be written in Python, while calling the low-level
> C+assembler stuff. But as I said, it's _so_ completely different from
> anything else in use today as to make it pretty much a theorethical or
> academic exercise with little practical use. I can't see a project
> like that taking off, even if I would love to see it working.

I can state from first-hand experience that this idea is not too
far-fetched. It is possible to enable Python to express device drivers
and low level OS functions like multitasking with an amazingly small
amount of C+asm; I'd say around 2000 lines, excluding the Python
runtime. If Pyrex counts as not-C, then I bet it could be done in 500.

The performance problems are a bit harder, but with a good JIT compiling
VM the runtime performance of Python could theoretically come very close
to C.

I do agree though that there is little point in rewriting Linux in
Python. The advantage in Python is its expressiveness, but by rewriting
an existing system you gain nothing.



More information about the Python-list mailing list