micropython/tests/import
Damien George b5ebfadbd6 py: Compress first part of bytecode prelude.
The start of the bytecode prelude contains 6 numbers telling the amount of
stack needed for the Python values and exceptions, and the signature of the
function.  Prior to this patch these numbers were all encoded one after the
other (2x variable unsigned integers, then 4x bytes), but using so many
bytes is unnecessary.

An entropy analysis of around 150,000 bytecode functions from the CPython
standard library showed that the optimal Shannon coding would need about
7.1 bits on average to encode these 6 numbers, compared to the existing 48
bits.

This patch attempts to get close to this optimal value by packing the 6
numbers into a single, varible-length unsigned integer via bit-wise
interleaving.  The interleaving scheme is chosen to minimise the average
number of bytes needed, and at the same time keep the scheme simple enough
so it can be implemented without too much overhead in code size or speed.
The scheme requires about 10.5 bits on average to store the 6 numbers.

As a result most functions which originally took 6 bytes to encode these 6
numbers now need only 1 byte (in 80% of cases).
2019-10-01 12:26:22 +10:00
..
pkg tests: Split out those tests requiring float and import. 2014-04-17 16:21:43 +01:00
pkg2 tests: Split out those tests requiring float and import. 2014-04-17 16:21:43 +01:00
pkg3 tests: Split out those tests requiring float and import. 2014-04-17 16:21:43 +01:00
pkg6 tests: Add another testcase for relative imports. 2015-02-16 12:11:41 +02:00
pkg7 tests/import: Update comment now that uPy raises correct exception. 2017-06-28 12:21:29 +10:00
pkg8 tests/import: Improve builtinimport.c test coverage. 2017-01-16 15:59:33 +11:00
builtin_import.py tests/import: Add a test for the builtin __import__ function. 2017-06-28 12:21:29 +10:00
gen_context2.py tests: Move gen_context to import tests, because it relies on import. 2014-04-17 23:21:52 +01:00
gen_context.py tests: Move gen_context to import tests, because it relies on import. 2014-04-17 23:21:52 +01:00
import1a.py tests: Split out those tests requiring float and import. 2014-04-17 16:21:43 +01:00
import1b.py tests: Split out those tests requiring float and import. 2014-04-17 16:21:43 +01:00
import2a.py tests: Improve test coverage of py/compile.c. 2016-10-11 12:30:32 +11:00
import3a.py tests: Split out those tests requiring float and import. 2014-04-17 16:21:43 +01:00
import_file.py py: Implement __file__ attribute for modules. 2014-07-28 21:21:59 +03:00
import_long_dyn2.py tests/import_long_dyn: Test for "import *" of a long dynamic name. 2018-11-01 13:33:16 +11:00
import_long_dyn.py tests/import_long_dyn: Test for "import *" of a long dynamic name. 2018-11-01 13:33:16 +11:00
import_override.py tests: Add tests for overriding builtins.__import__. 2019-07-31 22:37:44 +10:00
import_pkg1.py tests/import: Add test for compiling "import a.b as c". 2016-09-30 14:48:22 +10:00
import_pkg2.py tests: Rename test scripts, changing - to _ for consistency. 2014-07-05 06:14:29 +01:00
import_pkg3.py tests: Rename test scripts, changing - to _ for consistency. 2014-07-05 06:14:29 +01:00
import_pkg4.py tests: Rename test scripts, changing - to _ for consistency. 2014-07-05 06:14:29 +01:00
import_pkg5.py tests: Rename test scripts, changing - to _ for consistency. 2014-07-05 06:14:29 +01:00
import_pkg6.py tests: Add another testcase for relative imports. 2015-02-16 12:11:41 +02:00
import_pkg7.py tests/import: Improve builtinimport.c test coverage. 2017-01-16 15:59:33 +11:00
import_pkg8.py tests/import: Improve builtinimport.c test coverage. 2017-01-16 15:59:33 +11:00
module_getattr.py py/objmodule: Implement PEP 562's __getattr__ for modules. 2018-10-23 11:22:50 +11:00
module_getattr.py.exp tests/import: Add .exp file for module_getattr.py to not require Py 3.7. 2018-10-23 11:56:58 +11:00
mpy_invalid.py py/persistentcode: Add a qstr window to save mpy files more efficiently. 2019-03-05 16:25:07 +11:00
mpy_invalid.py.exp py/persistentcode: Add a qstr window to save mpy files more efficiently. 2019-03-05 16:25:07 +11:00
mpy_native.py py: Compress first part of bytecode prelude. 2019-10-01 12:26:22 +10:00
mpy_native.py.exp tests/import: Add test for importing x64 native code. 2019-03-08 17:20:17 +11:00
rel_import_inv.py tests: Add test for relative import without package context. 2015-06-27 00:40:22 +03:00
try_module.py tests: Rename test scripts, changing - to _ for consistency. 2014-07-05 06:14:29 +01:00