<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openmano-mpy/tests/import, branch master</title>
<subtitle>MicroPython source and hardware configuration for OpenMano</subtitle>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/'/>
<entry>
<title>tests: Move .mpy import tests from import/ to micropython/ dir.</title>
<updated>2020-07-26T12:04:31+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2020-07-26T04:30:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=0c0cef9870e8215d67c79fefa6582849842001f9'/>
<id>0c0cef9870e8215d67c79fefa6582849842001f9</id>
<content type='text'>
These tests are specific to MicroPython so have a better home in the
micropython/ test subdir, and putting them here allows them to be run by
all targets, not just those that have access to the local filesystem (eg
the unix port).

Signed-off-by: Damien George &lt;damien@micropython.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These tests are specific to MicroPython so have a better home in the
micropython/ test subdir, and putting them here allows them to be run by
all targets, not just those that have access to the local filesystem (eg
the unix port).

Signed-off-by: Damien George &lt;damien@micropython.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tests: Format all Python code with black, except tests in basics subdir.</title>
<updated>2020-03-30T02:21:58+00:00</updated>
<author>
<name>David Lechner</name>
</author>
<published>2020-03-23T02:26:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=3dc324d3f1312e40d3a8ed87e7244966bb756f26'/>
<id>3dc324d3f1312e40d3a8ed87e7244966bb756f26</id>
<content type='text'>
This adds the Python files in the tests/ directory to be formatted with
./tools/codeformat.py.  The basics/ subdirectory is excluded for now so we
aren't changing too much at once.

In a few places `# fmt: off`/`# fmt: on` was used where the code had
special formatting for readability or where the test was actually testing
the specific formatting.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds the Python files in the tests/ directory to be formatted with
./tools/codeformat.py.  The basics/ subdirectory is excluded for now so we
aren't changing too much at once.

In a few places `# fmt: off`/`# fmt: on` was used where the code had
special formatting for readability or where the test was actually testing
the specific formatting.
</pre>
</div>
</content>
</entry>
<entry>
<title>tests: Add .exp files for basics/parser and import/import_override.</title>
<updated>2019-12-13T03:20:47+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2019-12-13T02:49:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=624f4ca39bbbf9c89fce24f4051dcdd9417e59b1'/>
<id>624f4ca39bbbf9c89fce24f4051dcdd9417e59b1</id>
<content type='text'>
Because CPython 3.8.0 now produces different output:
- basics/parser.py: CPython does not allow '\\\n' as input.
- import/import_override: CPython imports _io.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Because CPython 3.8.0 now produces different output:
- basics/parser.py: CPython does not allow '\\\n' as input.
- import/import_override: CPython imports _io.
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/import: Add test for importing viper code with additional flags.</title>
<updated>2019-12-12T09:15:28+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2019-12-02T05:27:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=111d1ffb6473950274bb506e1a27c01b33ea3d61'/>
<id>111d1ffb6473950274bb506e1a27c01b33ea3d61</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>py/builtinimport: Raise exception on empty module name.</title>
<updated>2019-11-25T13:28:32+00:00</updated>
<author>
<name>Léa Saviot</name>
</author>
<published>2019-11-22T13:06:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=a7bc4d1a1455a8a5cdea53d7a2caf03c9320f460'/>
<id>a7bc4d1a1455a8a5cdea53d7a2caf03c9320f460</id>
<content type='text'>
To prevent a crash returning MP_OBJ_NULL.  A test is added for this case.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
To prevent a crash returning MP_OBJ_NULL.  A test is added for this case.
</pre>
</div>
</content>
</entry>
<entry>
<title>py/persistentcode: Make .mpy more compact with qstr directly in prelude.</title>
<updated>2019-10-15T05:56:27+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2019-10-10T04:30:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=23f0691fddfc35acd2f81f54b15ad2ecaa15c6d4'/>
<id>23f0691fddfc35acd2f81f54b15ad2ecaa15c6d4</id>
<content type='text'>
Instead of encoding 4 zero bytes as placeholders for the simple_name and
source_file qstrs, and storing the qstrs after the bytecode, store the
qstrs at the location of these 4 bytes.  This saves 4 bytes per bytecode
function stored in a .mpy file (for example lcd160cr.mpy drops by 232
bytes, 4x 58 functions).  And resulting code size is slightly reduced on
ports that use this feature.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of encoding 4 zero bytes as placeholders for the simple_name and
source_file qstrs, and storing the qstrs after the bytecode, store the
qstrs at the location of these 4 bytes.  This saves 4 bytes per bytecode
function stored in a .mpy file (for example lcd160cr.mpy drops by 232
bytes, 4x 58 functions).  And resulting code size is slightly reduced on
ports that use this feature.
</pre>
</div>
</content>
</entry>
<entry>
<title>py/compile: Disallow 'import *' outside module level.</title>
<updated>2019-10-04T06:46:47+00:00</updated>
<author>
<name>Petr Viktorin</name>
</author>
<published>2019-09-20T07:16:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=25a9bccdee2fe830046c1c1a0220ca7706597202'/>
<id>25a9bccdee2fe830046c1c1a0220ca7706597202</id>
<content type='text'>
This check follows CPython's behaviour, because 'import *' always populates
the globals with the imported names, not locals.

Since it's safe to do this (doesn't lead to a crash or undefined behaviour)
the check is only enabled for MICROPY_CPYTHON_COMPAT.

Fixes issue #5121.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This check follows CPython's behaviour, because 'import *' always populates
the globals with the imported names, not locals.

Since it's safe to do this (doesn't lead to a crash or undefined behaviour)
the check is only enabled for MICROPY_CPYTHON_COMPAT.

Fixes issue #5121.
</pre>
</div>
</content>
</entry>
<entry>
<title>py: Rework and compress second part of bytecode prelude.</title>
<updated>2019-10-01T02:26:22+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2019-09-25T05:45:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=c8c0fd4ca39fbdcf9ca5f2fc99ca4d6b81a28b65'/>
<id>c8c0fd4ca39fbdcf9ca5f2fc99ca4d6b81a28b65</id>
<content type='text'>
This patch compresses the second part of the bytecode prelude which
contains the source file name, function name, source-line-number mapping
and cell closure information.  This part of the prelude now begins with a
single varible length unsigned integer which encodes 2 numbers, being the
byte-size of the following 2 sections in the header: the "source info
section" and the "closure section".  After decoding this variable unsigned
integer it's possible to skip over one or both of these sections very
easily.

This scheme saves about 2 bytes for most functions compared to the original
format: one in the case that there are no closure cells, and one because
padding was eliminated.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch compresses the second part of the bytecode prelude which
contains the source file name, function name, source-line-number mapping
and cell closure information.  This part of the prelude now begins with a
single varible length unsigned integer which encodes 2 numbers, being the
byte-size of the following 2 sections in the header: the "source info
section" and the "closure section".  After decoding this variable unsigned
integer it's possible to skip over one or both of these sections very
easily.

This scheme saves about 2 bytes for most functions compared to the original
format: one in the case that there are no closure cells, and one because
padding was eliminated.
</pre>
</div>
</content>
</entry>
<entry>
<title>py: Compress first part of bytecode prelude.</title>
<updated>2019-10-01T02:26:22+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2019-09-16T12:12:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=b5ebfadbd615de42c43851f27a062bacd9147996'/>
<id>b5ebfadbd615de42c43851f27a062bacd9147996</id>
<content type='text'>
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).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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).
</pre>
</div>
</content>
</entry>
<entry>
<title>py/persistentcode: Bump .mpy version to 5.</title>
<updated>2019-09-26T06:39:37+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2019-09-26T06:39:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=5716c5cf65e9b2cb46c2906f40302401bdd27517'/>
<id>5716c5cf65e9b2cb46c2906f40302401bdd27517</id>
<content type='text'>
The bytecode opcodes have changed (there are more, and they have been
reordered).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The bytecode opcodes have changed (there are more, and they have been
reordered).
</pre>
</div>
</content>
</entry>
</feed>
