# Python fluent.runtime - plans

**URL:** <https://discourse.mozilla.org/t/python-fluent-runtime-plans/35290>\
**Category:** Fluent\
**Tags:** l10n\
**Created:** [January 21, 2019, 6:35pm UTC](https://discourse.mozilla.org/t/python-fluent-runtime-plans/35290 "2019-01-21T18:35:10Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Pike](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/pike/32/20587_2.png) [@Pike](https://discourse.mozilla.org/u/Pike)\
**Post date:** [January 25, 2019, 9:51am UTC](https://discourse.mozilla.org/t/python-fluent-runtime-plans/35290/10 "2019-01-25T09:51:54Z")

</div>

Thanks for the response, getting to an ‘exec-free’ compiler was what I had in mind.

I actually thought I should make that more tangible, so I mocked something up last night, and given it just a little bit of polish this morning.

I’ve put that code up on [https://gist.github.com/Pike/1faef13e891a73c9835bf4b895c59987](https://gist.github.com/Pike/1faef13e891a73c9835bf4b895c59987).

The starting point is a runtime tree, which can be instantiated either for a resource or just an entry. Most of the AST constructs in the parser have a matching runtime AST, I just dropped some abstract base classes, I think.

The ` __call__ ` methods on those would effectively be what your code generator would create, to a significant part. Only the literals and pattern are interesting. I see that my `NumberLiteral` is a good deal away from your implementation stil.

The `Compiler` class is just the visitor that transforms parser-\>runtime, plus an optimizer. I’ve demoed taking string literals out of placeables, and concating string literals in patterns, and fast-forwarding simple text instead of pattern expression.

Obviously, that code isn’t even trying to be complete 😉

Ideas based on that concept that go around in my head:

- create a `class IsolatingVarRef(VariableReference)` when isolation is wanted
- keep `parsed` and `runnable` members on bundle, and only compile messages on demand
- loop detection could be done at compile time, depending on whether we’d want loop detection to kick in on any possible loop, or just when actually triggering a loop

I did also spend more time looking at your compiler branch, and just want to emphasize that I realize how much energy you’ve put into that.

---

_[View the full topic](https://discourse.mozilla.org/t/python-fluent-runtime-plans/35290)._
