[Python-Dev] Python for small platforms
M.-A. Lemburg
mal@lemburg.com
Tue, 11 Apr 2000 23:31:46 +0200
Jeff Collins wrote:
>
> The approach I've taken for removing "features" (like float objects):
> 1) removes the feature with WITHOUT_XXX #ifdef/#endif decorations,
> where XXX denotes the removable feature (configurable in config.h)
> 2) preserves the python API: builtin functions, C API, PyArg_Parse,
> print format specifiers, etc., raise MissingFeatureError if
> attempts are made to use them. Of course, the API associated
> with the removed feature is no longer present.
> 3) protects the reduced VM: all reads (via marshal, compile, etc.)
> involving source/compiled python code will fail with
> a MissingFeatureError if the reduced VM doesn't support it.
> 4) does not yet support a MissingFeatureError in the tokenizer
> if, say, 2.2 (for removed floats) is entered on the python
> command line. This instead results in a SyntaxError
> indicating a problem with the decimal point. It appears that
> another error token would have to be added to support
> this error.
Wouldn't it be simpler to replace the parts in question
with dummy replacements ? The dummies could then raise
appropriate exceptions as needed. This would work for
float, complex and Unicode objects which all have a defined
API.
The advantage of this approach is that you don't need to maintain
separate patches for these parts (which is a pain) and that you
can provide drop-in archives which are easy to install: simply
unzip over the full source tree and recompile.
> Of course, I may have missed something, but if the above appears to be
> a reasonable approach, I can supply patches (at least for floats and
> complexes) for further discussion. In the longer term, it would be
> helpful if developers would follow this (or a similar agreed upon
> approach) when adding new features. This would reduce the burden of
> maintaining python for small embedded platforms.
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/