{"action":"created","issue":{"url":"https://api.github.com/repos/micropython/micropython/issues/2709","repository_url":"https://api.github.com/repos/micropython/micropython","labels_url":"https://api.github.com/repos/micropython/micropython/issues/2709/labels{/name}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/2709/comments","events_url":"https://api.github.com/repos/micropython/micropython/issues/2709/events","html_url":"https://github.com/micropython/micropython/issues/2709","id":196804495,"number":2709,"title":"Compile Python Scripts On the Go","user":{"login":"timpur","id":7701482,"avatar_url":"https://avatars.githubusercontent.com/u/7701482?v=3","gravatar_id":"","url":"https://api.github.com/users/timpur","html_url":"https://github.com/timpur","followers_url":"https://api.github.com/users/timpur/followers","following_url":"https://api.github.com/users/timpur/following{/other_user}","gists_url":"https://api.github.com/users/timpur/gists{/gist_id}","starred_url":"https://api.github.com/users/timpur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timpur/subscriptions","organizations_url":"https://api.github.com/users/timpur/orgs","repos_url":"https://api.github.com/users/timpur/repos","events_url":"https://api.github.com/users/timpur/events{/privacy}","received_events_url":"https://api.github.com/users/timpur/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-12-20T23:06:50Z","updated_at":"2016-12-23T11:04:09Z","closed_at":null,"body":"I was wondering if it was possible to compile python scripts on the go. The idea would be you can upload a script (.py) file to the board and get the board to compile and save the compiled code. No need to build custom firmware. The compiled script don't need to be loaded into ram and run from flash, just like the firmware and core modules.\r\n\r\nThe reason is, it would be nice for newbie (me a month ago) who doesn't know the complexity of creating a firmware to be able to have the benefits of frozen scripts (Minimum Ram Usage)  without going to the trouble of setting up the SDK.\r\n\r\nHaving feature would also be awesome because, say you had an IOT device located remotely. You could webrepl into the device, upload a new script (.py) compile it on the board, move it to the lib folder (or something), remove the script (.py) and execute the new compiled script from flash. Now doesn't take any time to compile or use any ram to execute (the script doesn't live in ram, unlike .py scripts)\r\n\r\nThe saved compiled version could be a .mpy or .pyc, not sure about the details, that's why im asking you, the awesome developers. **What do you think of a feature like this and is it possible?** Tell me your thoughts.\r\n\r\nIt would be nice to create \"Frozen Scripts\" with out creating a custom firmware. **Lets use that awesome builtin Interpreter to its full potential.** \r\n\r\n**Functionality:**\r\n\r\n- Python Scrips compiled on board and saved as a file in the flash\r\n\r\n- Compiled Scripts execute from flash (no loading into ram)\r\n\r\n**Outcome:** \r\nMinimum Ram Usage for custom scripts."},"comment":{"url":"https://api.github.com/repos/micropython/micropython/issues/comments/268974079","html_url":"https://github.com/micropython/micropython/issues/2709#issuecomment-268974079","issue_url":"https://api.github.com/repos/micropython/micropython/issues/2709","id":268974079,"user":{"login":"robert-hh","id":12476868,"avatar_url":"https://avatars.githubusercontent.com/u/12476868?v=3","gravatar_id":"","url":"https://api.github.com/users/robert-hh","html_url":"https://github.com/robert-hh","followers_url":"https://api.github.com/users/robert-hh/followers","following_url":"https://api.github.com/users/robert-hh/following{/other_user}","gists_url":"https://api.github.com/users/robert-hh/gists{/gist_id}","starred_url":"https://api.github.com/users/robert-hh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robert-hh/subscriptions","organizations_url":"https://api.github.com/users/robert-hh/orgs","repos_url":"https://api.github.com/users/robert-hh/repos","events_url":"https://api.github.com/users/robert-hh/events{/privacy}","received_events_url":"https://api.github.com/users/robert-hh/received_events","type":"User","site_admin":false},"created_at":"2016-12-23T11:04:09Z","updated_at":"2016-12-23T11:04:09Z","body":"So I can imagine two possible use cases for the on-board compile:\r\n1. w/o files: compile a script during loading and load it into flash into the space, where frozen bytcode resides. The dictionary would have to be extended, and some kind of space management would be required (startof free ares + length or remaining space). That would be extend-only. Erasing by re-flash of the device, Advantage for the user:  Just a raw repl access needed, which woudl be possible for almost any platform/any device.\r\n2. with files: Compile on-board from a .py file or raw code coming in though the terminal interface into a .mpy file. The advantage for the user: no need for a cross compiler on the external platform.\r\n\r\nIn any case, the compile could support also platform specific properties like compile of native/viper/assembler code), which b.t.w. the cross compiler could already support now during creating of  aflash image.. The drawback would be the same: large code would still have to be compiled externally and loaded as .mpy file or embeded into the build, and so the biggest advantage of frozen bytecode would still not be achieved, at least for me.\r\nP.S.: Did someone ever think of making the frozen objects at least visible, like as read-only special objects in the file system? "}}
{"actor":{"display_login":"robert-hh"}}