<feed xmlns='http://www.w3.org/2005/Atom'>
<title>openmano-mpy/tests/cmdline, 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>unix: Improve command line argument processing.</title>
<updated>2021-04-07T02:41:25+00:00</updated>
<author>
<name>stijn</name>
</author>
<published>2021-04-06T18:40:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=a66286f3a0f24985cae2648102e51de64b8a1871'/>
<id>a66286f3a0f24985cae2648102e51de64b8a1871</id>
<content type='text'>
Per CPython everything which comes after the command, module or file
argument is not an option for the interpreter itself.  Hence the processing
of options should stop when encountering those, and the remainder be passed
as sys.argv.  Note the latter was already the case for a module or file but
not for a command.

This fixes issues like 'micropython myfile.py -h' showing the help and
exiting instead of passing '-h' as sys.argv[1], likewise for
'-X &lt;something&gt;' being treated as a special option no matter where it
occurs on the command line.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Per CPython everything which comes after the command, module or file
argument is not an option for the interpreter itself.  Hence the processing
of options should stop when encountering those, and the remainder be passed
as sys.argv.  Note the latter was already the case for a module or file but
not for a command.

This fixes issues like 'micropython myfile.py -h' showing the help and
exiting instead of passing '-h' as sys.argv[1], likewise for
'-X &lt;something&gt;' being treated as a special option no matter where it
occurs on the command line.
</pre>
</div>
</content>
</entry>
<entry>
<title>unix/variants: Enable MICROPY_DEBUG_PARSE_RULE_NAME on coverage build.</title>
<updated>2020-10-01T05:26:43+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2020-09-30T13:35:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=817b80a102a413b6458ea391bb2c463aff99672e'/>
<id>817b80a102a413b6458ea391bb2c463aff99672e</id>
<content type='text'>
Signed-off-by: Damien George &lt;damien@micropython.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Damien George &lt;damien@micropython.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>py/compile: Implement PEP 572, assignment expressions with := operator.</title>
<updated>2020-06-16T12:02:24+00:00</updated>
<author>
<name>Damien George</name>
</author>
<published>2020-06-16T11:42:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=178395031157f61af5426add2de1d76d91440b21'/>
<id>178395031157f61af5426add2de1d76d91440b21</id>
<content type='text'>
The syntax matches CPython and the semantics are equivalent except that,
unlike CPython, MicroPython allows using := to assign to comprehension
iteration variables, because disallowing this would take a lot of code to
check for it.

The new compile-time option MICROPY_PY_ASSIGN_EXPR selects this feature and
is enabled by default, following MICROPY_PY_ASYNC_AWAIT.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The syntax matches CPython and the semantics are equivalent except that,
unlike CPython, MicroPython allows using := to assign to comprehension
iteration variables, because disallowing this would take a lot of code to
check for it.

The new compile-time option MICROPY_PY_ASSIGN_EXPR selects this feature and
is enabled by default, following MICROPY_PY_ASYNC_AWAIT.
</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/cmdline: Add test for MICROPYINSPECT environment variable.</title>
<updated>2020-02-04T06:54:31+00:00</updated>
<author>
<name>David Lechner</name>
</author>
<published>2020-02-02T03:10:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=4a97f7aaf3c9123a7f127d6986b0f61ce9361beb'/>
<id>4a97f7aaf3c9123a7f127d6986b0f61ce9361beb</id>
<content type='text'>
When this variable is set to non-empty string it triggers the REPL after a
command/module/file finishes running.

The Python file without the file extension is because the cmdline: parser
in run-test splits on spaces, so we can't use the -c option since
`import os` can't be written without a space.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When this variable is set to non-empty string it triggers the REPL after a
command/module/file finishes running.

The Python file without the file extension is because the cmdline: parser
in run-test splits on spaces, so we can't use the -c option since
`import os` can't be written without a space.
</pre>
</div>
</content>
</entry>
<entry>
<title>tests/cmdline/repl_inspect: Add new test for -i option.</title>
<updated>2020-02-04T06:53:06+00:00</updated>
<author>
<name>David Lechner</name>
</author>
<published>2020-01-15T18:37:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=7c24f5528582ff1f50a0b24dd360e65342b1fd0c'/>
<id>7c24f5528582ff1f50a0b24dd360e65342b1fd0c</id>
<content type='text'>
This adds a new test to verify that the inspect (-i) command line option
works.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This adds a new test to verify that the inspect (-i) command line option
works.
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/mp-readline: Add word-based move/delete EMACS key sequences.</title>
<updated>2020-01-12T02:09:27+00:00</updated>
<author>
<name>Yonatan Goldschmidt</name>
</author>
<published>2019-12-14T21:42:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.0x7felf.com/openmano-mpy/commit/?id=853aaa06f24c98191a44a38eedd4ec2a0e63d3eb'/>
<id>853aaa06f24c98191a44a38eedd4ec2a0e63d3eb</id>
<content type='text'>
This commit adds backward-word, backward-kill-word, forward-word,
forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B,
Alt+D and Alt+Backspace respectively.  It is disabled by default and can be
enabled via MICROPY_REPL_EMACS_WORDS_MOVE.

Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings
for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W.

The features are enabled on unix micropython-coverage and micropython-dev.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds backward-word, backward-kill-word, forward-word,
forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B,
Alt+D and Alt+Backspace respectively.  It is disabled by default and can be
enabled via MICROPY_REPL_EMACS_WORDS_MOVE.

Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings
for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W.

The features are enabled on unix micropython-coverage and micropython-dev.
</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>
</feed>
