talin at acm.org
Mon Sep 25 11:27:57 CEST 2006
Milan Krcmar wrote:
> Thank you people. I'm going to try to strip unneeded things and let you
> know the result.
> Along with running Python on an embedded system, I am considering two
> more things. Suppose the system to be a small Linux router, which, after
> the kernel starts, merely configures lots of parameters of the kernel
> and then runs some daemons for gathering statistics and allowing remote
> control of the host.
> Python helps mainly in the startup phase of configuring kernel according
> to a human-readable confgiuration files. This has been solved by shell
> scripts. Python is not as suitable for running external processes and
> process pipes as a shell, but I'd like to write a module (at least)
> helping him in the sense of scsh (a "Scheme shell",
> A more advanced solution is to replace system's init (/sbin/init) by
> Python. It should even speed the startup up as it will not need to run
> shell many times. To avoid running another processes, I want to "port
> them" to Python. Processes for kernel configuration, like iproute2,
> iptables etc. are often built above its own library, which can be used as
> a start point. (Yes, it does matter, at startup, routers run such processes
> hundreds times).
One alternative you might want to look into is the language "Lua"
(www.lua.org), which is similar to Python in some respects (also has
embedding in larger apps - meaning that it has a much smaller footprint,
a much smaller standard library, less built-in data types and so on.
(For example, dicts, lists, and objects are all merged into a single
type called a 'table', which is just a generic indexable container.)
Lua's C API consists of just a few dozen functions.
It's not as powerful as Python of course, although it's surprisingly
powerful for its size - it has closures, continuations, and all of the
goodness you would expect from a modern language. Lua provides
'meta-mechanisms' for extending the language rather than implementing
language features directly. So even though it's not a pure
object-oriented language, it provides mechanisms for implementing
classes and inheritance. And it's fast, since it has less baggage to
It has a few warts - for example, I don't like the fact that referring
to an undefined variable silently returns nil instead of returning an
error, but I suppose in some environments that's a feature.
A lot of game companies use Lua for embedded scripting languages in
their games. (Console-based games in particular have strict memory
requirements, since there's no virtual memory on consoles.)
More information about the Python-Dev