Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    pyc files and __pycache__

    Scheduled Pinned Locked Moved MicroPython
    pyccompiledeploy
    4 Posts 2 Posters 759 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      panda
      last edited by

      Should I be able to find the pycache and/or the pyc files somewhere on the Pycom device's flash after the py scripts have been executed? I don't think the compile() builtin exists in the Pycom firmware to script the creation of pyc files.

      Goal is to use bytecode versions of the scripts so that the source is not casually viewable on deployed devices. Also want to save some space so updates over LTE use minimal data.

      Should I be trying to find pyc files on the device to use for deployment? Or, I see I can use a cross compiler to create mpy bytecode files, but are these not on the device already and its another step to create them.

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @panda
        last edited by

        @panda You can use mpy-cross on your PC to create bytecode files, extension .mpy, which can be used like the source files. These files reside in the file system.
        Alternatively, if you take the challenge to set up the build system, you can embed these cross-compiled files in the flash, not visible in the file system. The compilation and embedding is part of the build process.
        I use to keep copies of the mpy-cross program here: https://github.com/robert-hh/Shared-Stuff
        I did not update that for a while, so I have to check whether these programs are still useful. The bytecode structure may have been changed with the last update of the MicroPython engine.

        1 Reply Last reply Reply Quote 0
        • P Offline
          panda
          last edited by

          @robert-hh I tried your mpy-cross_pycom on windows and it seemed to work just fine. Thanks.

          I'm not interested in embedding any modules into the firmware, but to confirm, you don't know of a way to access a local cache on the Pycom device that might have the compiled versions of the modules after they are imported?

          -AP

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @panda
            last edited by

            @panda After modules are imported, the compiled code resides in RAM.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom