micropython

Change of docs/rationale.txt

44:136f6bf70d3f
docs/rationale.txt
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docs/rationale.txt	Mon Feb 18 01:22:25 2008 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +Micropython: A minimal implementation of Python for constrained devices
     1.5 +
     1.6 +  * Python provides a rich programming environment
     1.7 +  * CPython enforces the "official" language version
     1.8 +  * CPython, Jython, etc. expose the full strength language
     1.9 +
    1.10 +Motivations
    1.11 +
    1.12 +  * Run Python programs in "small" devices
    1.13 +  * Small programs
    1.14 +  * Few executed instructions
    1.15 +
    1.16 +Python's flexibility comes at a cost
    1.17 +
    1.18 +  * Modules, classes, instances are all objects
    1.19 +  * Freedom to modify most objects at any time
    1.20 +  * Difficult to predict eventual behaviour before execution
    1.21 +  * Difficult to generate optimisations when compiling
    1.22 +
    1.23 +Attribute access
    1.24 +
    1.25 +  * Must do a full lookup every time:
    1.26 +    * Check instance dictionary
    1.27 +    * Check class, superclasses
    1.28 +  * Potentially lots of code
    1.29 +  * Lots of executed instructions
    1.30 +
    1.31 +Other costly operations
    1.32 +
    1.33 +  * Keyword parameter resolution
    1.34 +  * Binary operators
    1.35 +  * Comparisons
    1.36 +
    1.37 +Examples of rarely used/unnecessary flexibility
    1.38 +
    1.39 +  * Can subclass dynamically:
    1.40 +
    1.41 +    for cls in A, B:
    1.42 +        class C(cls):
    1.43 +            pass
    1.44 +
    1.45 +  * Yet most people would relate to "class C"
    1.46 +  * Not "the class currently known as C"
    1.47 +
    1.48 +Examples of occasionally used flexibility
    1.49 +
    1.50 +  * Can evaluate classes and functions in dynamic contexts:
    1.51 +
    1.52 +    if platform == 'posix':
    1.53 +        class C:
    1.54 +            ...
    1.55 +    else:
    1.56 +        class C:
    1.57 +            ...
    1.58 +
    1.59 +  * Seen quite often in the standard library with functions
    1.60 +  * Dynamism used for configuration purposes
    1.61 +
    1.62 +Distinguish between "good" and "bad" dynamism
    1.63 +
    1.64 +  * Dynamic class preparation
    1.65 +  * Run-time choice of classes
    1.66 +  * Assigning attributes to modules
    1.67 +
    1.68 +Run-time configuration
    1.69 +
    1.70 +  * The source of a lot of "bad" dynamism
    1.71 +  * Comparable to, but more robust than...
    1.72 +    * Class loading tricks in Java
    1.73 +    * Dynamic library loading magic in C/C++
    1.74 +  * Has a place, but perhaps not in compiled, embedded programs