0

I need to write a binary file to store some BTree data for a college work. To simplify, I have a class BTree:

class BTree(MWayTree):

    def __init__(self, t):
        super(BTree, self).__init__(t)

        self._keys.setLength(self.keyLimit + 1)
        self._subTrees.setLength(self.keyLimit + 2)
        self._parent = None
        self._data = Array(self.keyLimit + 1)

    def ...

and a class TrieTree:

class TrieTree(SearchTree):

    def __init__(self, maxSubTrees):
        super(TrieTree, self).__init__()
        self._key = None
        self._datkea = []
        self._subTrees = Array(maxSubTrees + 65)
        self._maxSubTrees = maxSubTrees + 65


    def ...

and a list with some Trees based on them, something like:

trees = [BTree(10), TrieTree(4), BTree(1), ...]

Here's the deal, the data in the trees I read from a JSON file. I put the data in the trees and then I need to save this list on a binary file to be read by another function, which reads the binary file and the trees, and then does some searching through the data.

I've seen some topics here about writing binary files with python, but it's always string, int, float, etc, never seen with other data structures..

Anyway, can someone help? If it comes to it, instead of writing the list on the bin file, write each structure in a different file can be useful too..

martineau
  • 119,623
  • 25
  • 170
  • 301
alvarosps
  • 83
  • 1
  • 11

0 Answers0