btree lib support

  • I was looking for a very lightweight database-like (key-value pair) storage mechanism for micropython and stumbled across the btree micropython library but it is not included in Pycom's FW build. Is it easy to add, I cannot find single file which makes me think it is heavily dependent on C or something. I need a way to store records of RFID tags for example and then look it up as tag 'swipes' are detected. I cannot store this info in the cloud as the latency will be too high. Any ideas?
    Also found that calling



    object modules is of type str
      encode -- <function>
      find -- <function>
      rfind -- <function>
      index -- <function>

    This help command is suppose to list all the installed python modules?


  • @frida If jou are referring to Pycom's nvram key-value pair then no because it can only store a single 32bit int as the value. I want to save more information.

  • @robert-hh thanks for trying though. I must still learn about make files and all that cross compiling stuff. I'm used to IDEs that hide all that complexity from me :)

  • Can nvram be used?

  • @livius I don't necessarily need btree. Any memory efficient key-value pair will do. I thought about saving a dictionary to file via json but the issue is that depending on the number of elements, it might use up a lot of ram to read the whole file to json then to dictionary. I guess I can come up with a file scheme by saving certain ranges in seperate files.

  • @inverseeffect Including BTREE is not as easy as I assumed. All components are there, but the make files have to be aligned too.

  • @inverseeffect
    Do you really need btree? You say about key value pair. Dictionary is enough for that.
    Or do you really need some benefits from btree?

  • @inverseeffect The code for the btree moddule is in the repository, but not enabled in the standard build. You can do that, but you have to set up the build environment for that, add to esp32/mpconfigport.h the line

    #define MICROPY_PY_BTREE (1)

    and then build your target. I must confirm that I did not try that, so I'm not sure if it build w/o errors. But there is a good chance that it does. I can try this night.

Log in to reply

Pycom on Twitter