<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/runtime.c, branch v1.9.4</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.9.4</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.9.4'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2018-05-10T13:00:04+00:00</updated>
<entry>
<title>py/runtime: Add mp_load_method_protected helper which catches exceptions</title>
<updated>2018-05-10T13:00:04+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-05-10T13:00:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=bc87b862fd22afb38ed7392b69474286fa5fe19f'/>
<id>urn:sha1:bc87b862fd22afb38ed7392b69474286fa5fe19f</id>
<content type='text'>
This new helper function acts like mp_load_method_maybe but is wrapped in
an NLR handler so it can catch exceptions.  It prevents AttributeError from
propagating out, and optionally all other exceptions.  This helper can be
used to fully implement hasattr (see follow-up commit), and also for cases
where mp_load_method_maybe is used but it must now raise an exception.
</content>
</entry>
<entry>
<title>py: Don't include mp_optimise_value or opt_level() if compiler disabled.</title>
<updated>2018-04-04T04:24:03+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-04-04T04:24:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=3f420c0c27bd6daa5af39517925be55b9b9a9ab3'/>
<id>urn:sha1:3f420c0c27bd6daa5af39517925be55b9b9a9ab3</id>
<content type='text'>
Without the compiler enabled the mp_optimise_value is unused, and the
micropython.opt_level() function is not useful, so exclude these from the
build to save RAM and code size.
</content>
</entry>
<entry>
<title>py/runtime: Be sure that non-intercepted thrown object is an exception.</title>
<updated>2018-03-30T01:43:38+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-03-30T01:37:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=f50b64cab58025e080f994147b75a8ffc55d2b35'/>
<id>urn:sha1:f50b64cab58025e080f994147b75a8ffc55d2b35</id>
<content type='text'>
The VM expects that, if mp_resume() returns MP_VM_RETURN_EXCEPTION, then
the returned value is an exception instance (eg to add a traceback to it).
It's possible that a value passed to a generator's throw() is not an
exception so must be explicitly checked for if the thrown value is not
intercepted by the generator.

Thanks to @jepler for finding the bug.
</content>
</entry>
<entry>
<title>py/runtime: Check that keys in dicts passed as ** args are strings.</title>
<updated>2018-03-30T00:13:32+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-03-30T00:09:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=32807881954f106b9735de74fe984062a0815b81'/>
<id>urn:sha1:32807881954f106b9735de74fe984062a0815b81</id>
<content type='text'>
Prior to this patch the code would crash if a key in a ** dict was anything
other than a str or qstr.  This is because mp_setup_code_state() assumes
that keys in kwargs are qstrs (for efficiency).

Thanks to @jepler for finding the bug.
</content>
</entry>
<entry>
<title>py/vm: Simplify handling of special-case STOP_ITERATION in yield from.</title>
<updated>2018-02-27T04:48:09+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-02-27T04:48:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a9f6d4921829195d7310aa8b07a4a705577161a5'/>
<id>urn:sha1:a9f6d4921829195d7310aa8b07a4a705577161a5</id>
<content type='text'>
There's no need to have MP_OBJ_NULL a special case, the code can re-use
the MP_OBJ_STOP_ITERATION value to signal the special case and the VM can
detect this with only one check (for MP_OBJ_STOP_ITERATION).
</content>
</entry>
<entry>
<title>py/builtinimport: Add compile-time option to disable external imports.</title>
<updated>2018-02-20T07:00:44+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2018-02-20T07:00:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=209936880df4d63730ea77cf4b6f84e5f2f56d7c'/>
<id>urn:sha1:209936880df4d63730ea77cf4b6f84e5f2f56d7c</id>
<content type='text'>
The new option is MICROPY_ENABLE_EXTERNAL_IMPORT and is enabled by default
so that the default behaviour is the same as before.  With it disabled
import is only supported for built-in modules, not for external files nor
frozen modules.  This allows to support targets that have no filesystem of
any kind and that only have access to pre-supplied built-in modules
implemented natively.
</content>
</entry>
<entry>
<title>py/runtime: Remove unnecessary break statements from switch.</title>
<updated>2017-12-19T02:13:21+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-12-19T02:13:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=f5fb68e94fe72a7d8c158a47c2374ee0cea0227c'/>
<id>urn:sha1:f5fb68e94fe72a7d8c158a47c2374ee0cea0227c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/runtime: Use the Python stack when building *arg and **kwarg state.</title>
<updated>2017-12-11T02:49:09+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-11-26T12:48:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=30fd8484ebe41faad467fbc8dd4a6f72250f203c'/>
<id>urn:sha1:30fd8484ebe41faad467fbc8dd4a6f72250f203c</id>
<content type='text'>
With MICROPY_ENABLE_PYSTACK enabled the following language constructs no
longer allocate on the heap: f(*arg), f(**kwarg).
</content>
</entry>
<entry>
<title>py: Convert all uses of alloca() to use new scoped allocation API.</title>
<updated>2017-12-11T02:49:09+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-11-26T12:37:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=1e5a33df413bbd8a8aa5bd880be445c684fc5506'/>
<id>urn:sha1:1e5a33df413bbd8a8aa5bd880be445c684fc5506</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py: Introduce a Python stack for scoped allocation.</title>
<updated>2017-12-11T02:49:09+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2017-11-26T12:28:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=02d830c035aca166d70551e485ccd2d1658189c9'/>
<id>urn:sha1:02d830c035aca166d70551e485ccd2d1658189c9</id>
<content type='text'>
This patch introduces the MICROPY_ENABLE_PYSTACK option (disabled by
default) which enables a "Python stack" that allows to allocate and free
memory in a scoped, or Last-In-First-Out (LIFO) way, similar to alloca().

A new memory allocation API is introduced along with this Py-stack.  It
includes both "local" and "nonlocal" LIFO allocation.  Local allocation is
intended to be equivalent to using alloca(), whereby the same function must
free the memory.  Nonlocal allocation is where another function may free
the memory, so long as it's still LIFO.

Follow-up patches will convert all uses of alloca() and VLA to the new
scoped allocation API.  The old behaviour (using alloca()) will still be
available, but when MICROPY_ENABLE_PYSTACK is enabled then alloca() is no
longer required or used.

The benefits of enabling this option are (or will be once subsequent
patches are made to convert alloca()/VLA):
- Toolchains without alloca() can use this feature to obtain correct and
  efficient scoped memory allocation (compared to using the heap instead
  of alloca(), which is slower).
- Even if alloca() is available, enabling the Py-stack gives slightly more
  efficient use of stack space when calling nested Python functions, due to
  the way that compilers implement alloca().
- Enabling the Py-stack with the stackless mode allows for even more
  efficient stack usage, as well as retaining high performance (because the
  heap is no longer used to build and destroy stackless code states).
- With Py-stack and stackless enabled, Python-calling-Python is no longer
  recursive in the C mp_execute_bytecode function.

The micropython.pystack_use() function is included to measure usage of the
Python stack.
</content>
</entry>
</feed>
