[Microbit-Python] memory error

David Whale david at thinkingbinaries.com
Fri Oct 2 17:54:58 CEST 2015


>Yes, I'm still thinking about this.  It currently parses the whole
source into an AST.  Will reply fully once I have something sensible
to say!

Ok thanks - when I've done this before, you sometimes need a fixup table
that you collect along the way, and do a final "tiny pass" to resolve jump
targets to things that are not known on the first pass, but the fixup table
+ implicit AST on machine stack is usually significantly smaller in terms
of memory footprint, and generally doesn't expand as the script size
expands, it only expands as the parse depth expands (e.g. a complex nested
algebraic expression would expand the temporary AST on the stack until the
final close bracket is seen).

Cheers

David.

___________________________________________________________
David Whale, B.Sc (Hons), MIET
*Software Engineer and IET Schools Liaison Officer, Essex*

email:  dwhale at theiet.org
twitter: @whaleygeek
blog:  blog.whaleygeek.co.uk

Co-author of the new book "Adventures in Minecraft" <http://amzn.to/ZGfxZG>
- lets get kids coding!


On 2 October 2015 at 16:37, Damien George <damien.p.george at gmail.com> wrote:

> > I understand from Howard that Joe is working on a persistent memory store
> > (simulated EEPROM in flash) - could you use that in the future?
>
> Yes, definitely.  Although it depends on the API that Joe exposes.
>
> > Also, did you see my note about AST expansion - do you parse the whole
> > python source script into a complete explicit AST in RAM and then
> translate
> > that into bytecode in RAM, or do you use an implicit 'AST on the machine
> > stack' style of translation, effectively pipelining AST generation and
> > bytecode generation? The latter is significantly smaller in terms of RAM
> > requirements, and scales better regardless of the script complexity.
>
> Yes, I'm still thinking about this.  It currently parses the whole
> source into an AST.  Will reply fully once I have something sensible
> to say!
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/mailman/private/microbit/attachments/20151002/4b48dd77/attachment-0001.html>


More information about the Microbit mailing list